<?php  session_start();  if(!isset($_SESSION['sales'])){ header('location:login.php'); die();}include 'dbconn.php'; include 'inc/functions.php';include 'xyz.php';


$totalSum = array_sum($_POST['tCost']);
$myCode =code_pics(3); $receiptNo = code_pics(4);$addCost =draw_in('realCost');
$paying = collect('paying'); $diff = $addCost-$paying; 
$cus_id='';
if(is_numeric(draw_in('userName'))){ $cus_id =draw_in('userName'); }else{
	$data = array('frm_name'=>draw_in('userName'),'frm_phone'=>draw_in('userPhone'),'frm_email'=>draw_in('userEmail'),'frm_month'=>date('m'),'frm_year'=>date('Y'),'frm_date'=>date('Y-m-d'),'frm_time'=>time(),'staff_code'=>$_SESSION['sales'],'gender'=>draw_in('eqSex'),'cus_id'=>$myCode,'address'=>draw_in('myAddr'),'cus_type'=>draw_in('prog_type'));
	$linkr->insert('customers',$data);
	$cus_id =get_std_ID($myCode);
}
QueryDB("INSERT INTO partners VALUES('','".$cus_id."','".$addCost."','".implode(',',array_filter($_POST['Item']))."','".implode(',',array_filter($_POST['QTY']))."','".implode(',',array_filter($_POST['singleCost']))."','".implode(',',array_filter($_POST['tCost']))."','','".date('m')."','".date('Y')."','$receiptNo','".$_SESSION['sales']."','','$my_branch_code','".date('Y-m-d')."','0','".date('Y-m-d')."') ");






?>