0xV3NOMx
Linux ip-172-26-7-228 5.4.0-1103-aws #111~18.04.1-Ubuntu SMP Tue May 23 20:04:10 UTC 2023 x86_64



Your IP : 18.117.254.177


Current Path : /proc/thread-self/root/var/www/html/cnv/rcub/custom_src/
Upload File :
Current File : //proc/thread-self/root/var/www/html/cnv/rcub/custom_src/dashboard_customer.php

<?php
class dash
{
	public $internal_code;
	
		function __construct($aobj_context)
		{
			session_start();
			$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
			$this->aobj_context=$aobj_context;
			$this->user_id = $_SESSION['user_id'];		
			$this->user_type = $_SESSION['user_type'];
            $this->party_int_code = $aobj_context->mobj_data["ds_party_int_code"];	
			$this->enq_arr=array();	
			$this->quo_arr=array();	
			$this->co_arr=array();	
		} 
		function GetTaskGroups()
		{
			$get_usr_schema_data="SELECT internal_code, module_name
								 FROM s_user_schema 
								 WHERE module_name IN ('Invoice','Customer Order','Quotation','Enquiry')
								 ";
			$lobj_get_usr_schema_data = $this->aobj_context->mobj_db->GetAll($get_usr_schema_data); 					 
			$this->task_grp_int_arr=array();
			foreach($lobj_get_usr_schema_data as $k=>$v)
			{
				$this->task_grp_int_arr [$v[module_name]]=$v[internal_code];
			}
			//print_r($this->task_grp_int_arr ); die();
		}
		function FormTableData($data_set)
		{
			$header_row=array_keys($data_set[0]);
			$html="<table style=\"font-family:'Segoe UI'\"; class='table table-hover' cellpadding='0'cellspacing='0'>
									<thead>";
			$html.='<tr>';
			foreach($header_row as $k=>$v)
			{
					$v_a=explode(":",$v);
					$name=$v_a[0];
					$al=$v_a[1];
					$align="left";
					if(strtolower($al)=="l")
					$align="left";
					if(strtolower($al)=="c")
					$align="center";
					if(strtolower($al)=="r")
					$align="right";		 
					
						if($name=='IntCode')	
						$html.="<th style='display:none; text-align:{$align};'>{$name}</th>";
						else
						$html.="<th style='text-align:{$align};'>{$name}</th>";
			
			}
			$html.="</tr></thead><tbody>";	
										 
				//print_r($data_set); die();
				foreach($data_set as $key=>$val)
				{	 
					$html.='<tr>';
					foreach($val as $k=>$v)
					{				 
						$v_a=explode(":",$k);
						$name=$v_a[0];
						$al=$v_a[1];
						$align="left";
						if(strtolower($al)=="l")
						$align="left";
						if(strtolower($al)=="c")
						$align="center";
						if(strtolower($al)=="r")
						$align="right";	     				
				
						if($name=='IntCode')	
						$html.="<td style=\"display:none; font-family:'Segoe UI';font-size:14px;text-align:{$align};\">{$v}</td>";
						else if($name=='Enquery No')
                        {	 
							$enq_int_code=$this->enq_arr[$v];
							// echo $enq_int_code; die();
							$html.="<td style=\"font-family:'Segoe UI';font-size:11px; color:#A78BF9; cursor:pointer; text-align:{$align};\" onclick=\"GetDashboardPopups('enq_{$enq_int_code}','Enqury Pop up',{$enq_int_code})\" >{$v}</td>";
						}	
						else if($name=='Quotation No')
                        {	
							$quo_int_code=$this->quo_arr[$v];
							$html.="<td style=\"font-family:'Segoe UI';font-size:11px; color:#A78BF9; cursor:pointer; text-align:{$align};\" onclick=\"GetDashboardPopups('quo_{$quo_int_code}','Quotation Pop up',{$quo_int_code})\" >{$v}</td>";
						}
						else if($name=='Order No')
                        {	
							$co_int_code=$this->co_arr[$v];
							$html.="<td style=\"font-family:'Segoe UI';font-size:11px; color:#A78BF9; cursor:pointer; text-align:{$align};\" onclick=\"GetDashboardPopups('co_{$co_int_code}','Customer Order Pop up',{$co_int_code})\" >{$v}</td>";
						}
						else if($name=='Invoice No')
                        {	
							$inv_int_code=$this->co_arr[$v];
							$html.="<td style=\"font-family:'Segoe UI';font-size:11px; color:#A78BF9; cursor:pointer; text-align:{$align};\" onclick=\"GetDashboardPopups('inv_{$inv_int_code}','Invoice Pop up',{$inv_int_code})\" >{$v}</td>";
						}
						else
						$html.="<td style=\"font-family:'Segoe UI';font-size:14px;text-align:{$align};\">{$v}</td>";
					}
						$html.='</tr>';
				}		
				$html.="</tbody></table>";
			return $html;	
		}
		function GetEnqueryData()
		{
		   $get_cust_data="SELECT e.internal_code as 'IntCode',DATE_FORMAT(e.DATE,'%d/%m/%Y') AS 'Date:l',enq_no AS 'Enquery No:l','click on Enq No  for  product description'  AS 'Product:l',
							e.enq_ref AS 'Enquiry Ref:l',
						CASE 
							WHEN inv.enquiry_ref_no>0 THEN 'Invoice'
							WHEN co.enquiry_ref_no>0 THEN 'Customer Order'
							WHEN  q.enquiry_ref_no>0 THEN 'Quotation'
							ELSE 
							'New' END AS STATUS
							FROM enquiry e
							LEFT JOIN enquiry_items_group etg ON etg.ref_s_ref_data_code=e.internal_code
							LEFT JOIN product_master pm ON pm.internal_code=etg.product
							LEFT JOIN master_database md ON md.internal_code=e.party
							LEFT JOIN quotation q ON q.enquiry_ref_no=e.internal_code
							LEFT JOIN customer_order co ON co.enquiry_ref_no=e.internal_code
							LEFT JOIN invoice inv ON inv.enquiry_ref_no=e.internal_code
							where e.party={$this->party_int_code} group by e.enq_no " ;
							//echo $get_cust_data; die();
			$lobj_get_cust_data = $this->aobj_context->mobj_db->GetAll($get_cust_data);

          	foreach($lobj_get_cust_data as $ek=>$ev)
			{
			  $this->enq_arr[$ev['Enquery No:l']]=$ev['IntCode'];		
			}	
  					
			$this->enquery_table=$this->FormTableData($lobj_get_cust_data);
		}
		function GetQuotationData()
		{
		   $get_cust_data="SELECT q.internal_code as 'IntCode', DATE_FORMAT(q.DATE,'%d/%m/%Y') AS 'Date:l',quot_no AS 'Quotation No:l','click on Quote No  for  product description'  AS 'Product:l',
						CASE 
							WHEN inv.quote_ref_no>0 THEN 'Invoice'
							WHEN co.quote_ref_no>0 THEN 'Customer Order'
							ELSE 
							'New' END AS STATUS
							FROM quotation q
							LEFT JOIN quotation_items_group qtg ON qtg.ref_s_ref_data_code=q.internal_code
							LEFT JOIN product_master pm ON pm.internal_code=qtg.product
							LEFT JOIN master_database md ON md.internal_code=q.party
							LEFT JOIN customer_order co ON co.quote_ref_no=q.internal_code
							LEFT JOIN invoice inv ON inv.quote_ref_no=q.internal_code
							where q.party={$this->party_int_code} group by q.quot_no" ;
							//echo $get_cust_data; die();
			$lobj_get_cust_data = $this->aobj_context->mobj_db->GetAll($get_cust_data);	
			foreach($lobj_get_cust_data as $ek=>$ev)
			{
			  $this->quo_arr[$ev['Quotation No:l']]=$ev['IntCode'];		
			}				
			$this->quo_table=$this->FormTableData($lobj_get_cust_data);
		}
		function GetCustomerData()
		{
		   $get_cust_data="SELECT co.internal_code as 'IntCode',DATE_FORMAT(co.DATE,'%d/%m/%Y') AS 'Date:l',co_no AS 'Order No:l','click on Order No  for  product description'  AS 'Product:l',
						CASE 
							WHEN inv.customer_order_ref_no>0 THEN 'Invoice'
							ELSE 
							'New' END AS STATUS
							FROM customer_order co
							LEFT JOIN customer_order_items_group cotg ON cotg.ref_s_ref_data_code=co.internal_code
							LEFT JOIN product_master pm ON pm.internal_code=cotg.product
							LEFT JOIN invoice inv ON inv.customer_order_ref_no=co.internal_code
							where co.party={$this->party_int_code} group by co.co_no" ;
							//echo $get_cust_data; die();
			$lobj_get_cust_data = $this->aobj_context->mobj_db->GetAll($get_cust_data);	
			foreach($lobj_get_cust_data as $ek=>$ev)
			{
			  $this->co_arr[$ev['Order No:l']]=$ev['IntCode'];		
			}
			$this->cust_table=$this->FormTableData($lobj_get_cust_data);
		}	
		function GetInvoiceData()
		{
		   $get_cust_data="SELECT inv.internal_code as 'IntCode',DATE_FORMAT(inv.DATE,'%d/%m/%Y') AS 'Date:l',inv_no AS 'Invoice No:l',GROUP_CONCAT(pm.product_name) AS 'Product:l',
							'New'  AS STATUS
							FROM invoice inv
							LEFT JOIN invoice_items_group itg ON itg.ref_s_ref_data_code=inv.internal_code
							LEFT JOIN product_master pm ON pm.internal_code=itg.product
							inner join party_master p on p.internal_code=inv.party
							where p.ref_mast_db_int_code={$this->party_int_code} group by inv.inv_no" ;
							//echo $get_cust_data; die();
			$lobj_get_cust_data = $this->aobj_context->mobj_db->GetAll($get_cust_data);		
			foreach($lobj_get_cust_data as $ek=>$ev)
			{
			  $this->co_arr[$ev['Invoice No:l']]=$ev['IntCode'];		
			}
			$this->invoice_table=$this->FormTableData($lobj_get_cust_data);
		}
		
		function GetMyTasks()
		{
		   $get_my_task_data="SELECT t.internal_code AS task_id,							
									sy.real_name AS created_by,
									DATE_FORMAT(t.created_date,'%d-%b-%y') AS created_date,							
									DATE_FORMAT(t.target_date,'%d-%b-%y') AS target_date,
									DATE_FORMAT(t.next_follow_up,'%d-%b-%y') AS next_follow_up,
									um.emp_name as assigned_to,
									u.emp_name as followed_by,
									case 
									when t.target_date=current_date() then '#F29807'
									when t.target_date>current_date() then '#07F226'
									else
									'#F20722' end as target_date_color,
									SUBJECT,
									ts.status AS STATUS 
								FROM task t							
								INNER JOIN task_status ts ON ts.internal_code=t.status
								LEFT JOIN s_sysdb sy ON sy.internal_code=t.created_by
								LEFT JOIN user_master um ON um.internal_code=t.assigned_to
								LEFT JOIN user_master u ON u.internal_code=t.follow_up_by
								WHERE 1=1  and t.customer={$this->party_int_code}  AND ts.status!='Completed'
							";
							// echo $get_my_task_data; die();
				$lobj_get_my_task_data=  $this->aobj_context->mobj_db->GetAll($get_my_task_data);
			$this->my_task_html="";
			foreach($lobj_get_my_task_data as $mk=>$mv)
            {		
				$target_date_color=$mv[target_date_color];
             	$this->my_task_html.='<tr>						
						<td>'.$mv[task_id].'</td>
						<td>'.$mv[created_by].'</td>
						<td>'.$mv[created_date].'</td>
						<td>'.$mv[target_date].'</td>
						<td>'.$mv[assigned_to].'</td>
						<td>'.$mv[next_follow_up].'</td>
						<td>'.$mv[followed_by].'</td>
						<td style="color:'.$target_date_color.';">'.$mv[SUBJECT].'</td>						
						<td><span class="label label-'.$span_arr[$mv[STATUS]].'">'.$mv[STATUS].'</span></td>
						<td><span onclick=TaskOpener("'.$mv[task_id].'")><i class="icon-edit" style="cursor:pointer; padding:4px; font-size:12pt"></i></span><span onclick="EditTaskDetails('.$mv[task_id].');"><i class="icon-search" style="cursor:pointer; padding:4px; font-size:12pt"></span></td>					
						</tr>';				
			}
			// echo "<pre>";
			// print_r($this->my_task_html);die();
		}
		function FormCustomerDashboard()
		{
		   $this->GetTaskGroups();
		   $this->GetInvoiceData();
		   $this->GetCustomerData();
		   $this->GetQuotationData();
		   $this->GetEnqueryData();
		   $this->GetMyTasks();
		   $this->FormFinalHtml();
		}
		function FormFinalHtml()
		{
		$this->html="";		
		
		   $this->html='<div class="row-fluid"><div class="span6"><div class="portlet box red">
							<div class="portlet-title">
								<h4><i class="icon-bell"></i>Enquey</h4>
								<div class="tools">
									<a class="collapse" href="javascript:;"></a>									
									<a class="remove" href="javascript:;"></a>
								</div>
							</div>
							<div class="portlet-body" style="height:300px; overflow:auto;">
								 '.$this->enquery_table.'
						</div>
					</div>				
					</div>				
					 ';		
			$this->html.='<div class="span6"><div class="portlet box green">
							<div class="portlet-title">
								<h4><i class="icon-dashboard"></i>Quotation</h4>
								<div class="tools">
									<a class="collapse" href="javascript:;"></a>									
									<a class="remove" href="javascript:;"></a>
								</div>
							</div>
							<div class="portlet-body" style="height:300px; overflow:auto;">
								 '.$this->quo_table.'
						</div>
					</div>					
					</div>					
					</div>					
					 ';		
			$this->html.='<div class="row-fluid"><div class="span6" style="margin-left:0;"><div class="portlet box purple">
							<div class="portlet-title">
								<h4><i class="icon-shopping-cart"></i>Customer Order</h4>
								<div class="tools">
									<a class="collapse" href="javascript:;"></a>									
									<a class="remove" href="javascript:;"></a>
								</div>
							</div>
							<div class="portlet-body" style="height:300px; overflow:auto;">
								 '.$this->cust_table.'
						</div>
					</div>					
					</div>					
					 ';	
			$this->html.='<div class="span6"><div class="portlet box blue">
							<div class="portlet-title">
								<h4><i class="icon-money"></i>Invoice</h4>
								<div class="tools">
									<a class="collapse" href="javascript:;"></a>									
									<a class="remove" href="javascript:;"></a>
								</div>
							</div>
							<div class="portlet-body" style="height:300px; overflow:auto;">
								 '.$this->invoice_table.'
						</div>
					</div>					
					</div>					
					</div>					
					 ';
			$this->html.='<!-- MY TASK BEGIN CONDENSED TABLE PORTLET-->
							<div class="portlet box red">
								<div class="portlet-title">
									<h4><i class="icon-picture"></i>My Task</h4>
									<div class="tools">
										<a class="collapse" href="javascript:;"></a>									
										<a class="remove" href="javascript:;"></a>
									</div>
								</div>
								<div class="portlet-body" style="height:300px; overflow:auto;">
									<table class="table table-hover" cellpadding="0" cellspacing="0">
										<thead>
											<tr>											
												<th>Task Id</th>
												<th>Created by</th>
												<th>Created Date</th>
												<th>Target Date</th>
												<th>Assigned To</th>
												<th>Followed Date</th>
												<th>Followed By</th>
												<th>Subject</th>
												<th>Status</th>
												<th>Edit/View</th>
											</tr>
										</thead>
										<tbody>'.
											$this->my_task_html.'
										</tbody>
									</table>
								</div>
							</div>
					<!-- END CONDENSED TABLE PORTLET-->';
										
			$arr[cust_dash_board]=$this->html;
			 
			echo $this->aobj_context->mobj_output->ToJSONEnvelope($arr,0,"success");  
		}
 }
function GetCustomerDashboard($aobj_context)
{
	$obj=new dash($aobj_context);			
	$obj->FormCustomerDashboard();
}
?>