Current File : /home/inlingua/www/sensoriumpsychologists.com/franchise_between/invoice_funcs.php |
<?php
require_once("../../panel_end_point_hide/database_func.php");
class invoice_funcs
{
private $branch,$invoice_company_name,$invoice_header,$tin_no,$service_tax_no;
private $invoice_no,$invoice_status,$buyer,$buyer_address,$invoice_date,$delivery_note,$buyer_wo_number,$wo_date,$name_of_work,$delivery_material,$delivery_address,$site_in,$total_vat,$total_stax,$total_cst,$packing_and_forwarding,$total_bill,$amount_in_words,$order_generated_by,$payment_terms,$remarks,$created_by,$created_browser,$created_ip,$updated_by,$updated_browser,$updated_ip,$updated_date;
private $description=array();
private $rate=array();
private $quantity=array();
private $total_row=array();
private $tax=array();
private $tax_percent_total_1_code,$tax_percent_total_2_code,$tax_percent_total_3_code,$tax_percent_total_4_code,$tax_percent_total_5_code,$tax_percent_total_6_code,$tax_percent_total_7_code,$tax_percent_total_8_code,$tax_percent_total_9_code,$tax_percent_total_10_code;
private $tax_percent_total_1_val,$tax_percent_total_2_val,$tax_percent_total_3_val,$tax_percent_total_4_val,$tax_percent_total_5_val,$tax_percent_total_6_val,$tax_percent_total_7_val,$tax_percent_total_8_val,$tax_percent_total_9_val,$tax_percent_total_10_val;
private $amount,$cr_to_account,$due_date,$status,$payment_mode,$cheque_no,$cheque_date,$cheque_bank,$cheque_branch,$dd_no,$dd_date,$dd_bank,$dd_branch,$neft_no,$neft_date,$neft_bank,$neft_branch,$ecs_no,$ecs_date,$ecs_bank,$ecs_branch,$cash_paid_on,$cash_receipt_no,$payment_cleared_on;
public function __construct()
{
$this->branch="";
$this->invoice_company_name="";
$this->invoice_header="";
$this->tin_no="";
$this->service_tax_no="";
$this->branch="";
$this->invoice_no="";
$this->invoice_status="";
$this->buyer="";
$this->buyer_address="";
$this->invoice_date="0000-00-00";
$this->delivery_note="";
$this->buyer_wo_number="";
$this->wo_date="0000-00-00";
$this->name_of_work="";
$this->delivery_material="";
$this->delivery_address="";
$this->site_in="";
$this->total_vat="";
$this->total_stax="";
$this->total_cst="";
$this->packing_and_forwarding="";
$this->total_bill="";
$this->amount_in_words="";
$this->order_generated_by="";
$this->payment_terms="";
$this->remarks="";
$this->created_by="";
$this->created_browser="";
$this->created_ip="";
$this->updated_by="";
$this->updated_browser="";
$this->updated_ip="";
$this->amount="";
$this->cr_to_account="";
$this->due_date="0000-00-00";
$this->status="";
$this->payment_mode="";
$this->cheque_no="";
$this->cheque_date="0000-00-00";
$this->cheque_bank="";
$this->cheque_branch="";
$this->dd_no="";
$this->dd_date="0000-00-00";
$this->dd_bank="";
$this->dd_branch="";
$this->neft_no="";
$this->neft_date="0000-00-00";
$this->neft_bank="";
$this->neft_branch="";
$this->ecs_no="";
$this->ecs_date="0000-00-00";
$this->ecs_bank="";
$this->ecs_branch="";
$this->cash_paid_on="0000-00-00";
$this->cash_receipt_no="";
$this->payment_cleared_on="";
$this->remarks="";
$this->updated_date="0000-00-00 00:00:00";
}
public function set_value($variable_name,$new_value)
{
switch($variable_name)
{
case 'branch':$this->branch=$new_value;break;
case 'invoice_company_name':$this->invoice_company_name=$new_value;break;
case 'invoice_header':$this->invoice_header=$new_value;break;
case 'tin_no':$this->tin_no=$new_value;break;
case 'service_tax_no':$this->service_tax_no=$new_value;break;
case 'invoice_no':$this->invoice_no=$new_value;break;
case 'invoice_status':$this->invoice_status=$new_value;break;
case 'buyer':$this->buyer=$new_value;break;
case 'invoice_date':$this->invoice_date=$new_value;break;
case 'delivery_note':$this->delivery_note=$new_value;break;
case 'buyer_wo_number':$this->buyer_wo_number=$new_value;break;
case 'wo_date':$this->wo_date=$new_value;break;
case 'name_of_work':$this->name_of_work=$new_value;break;
case 'delivery_material':$this->delivery_material=$new_value;break;
case 'delivery_address':$this->delivery_address=$new_value;break;
case 'site_in':$this->site_in=$new_value;break;
case 'total_vat':$this->total_vat=$new_value;break;
case 'total_stax':$this->total_stax=$new_value;break;
case 'total_cst':$this->total_cst=$new_value;break;
case 'packing_and_forwarding':$this->packing_and_forwarding=$new_value;break;
case 'total_bill':$this->total_bill=$new_value;break;
case 'amount_in_words':$this->amount_in_words=$new_value;break;
case 'order_generated_by':$this->order_generated_by=$new_value;break;
case 'payment_terms':$this->payment_terms=$new_value;break;
case 'remarks':$this->remarks=$new_value;break;
case 'created_by':$this->created_by=$new_value;break;
case 'created_browser':$this->created_browser=$new_value;break;
case 'created_ip':$this->created_ip=$new_value;break;
case 'updated_by':$this->updated_by=$new_value;break;
case 'updated_browser':$this->updated_browser=$new_value;break;
case 'updated_ip':$this->updated_ip=$new_value;break;
case 'description':$this->description=$new_value;break;
case 'rate':$this->rate=$new_value;break;
case 'quantity':$this->quantity=$new_value;break;
case 'total_row':$this->total_row=$new_value;break;
case 'tax':$this->tax=$new_value;break;
case 'amount':$this->amount=$new_value;break;
case 'cr_to_account':$this->cr_to_account=$new_value;break;
case 'due_date':$this->due_date=$new_value;break;
case 'status':$this->status=$new_value;break;
case 'payment_mode':$this->payment_mode=$new_value;break;
case 'cheque_no':$this->cheque_no=$new_value;break;
case 'cheque_date':$this->cheque_date=$new_value;break;
case 'cheque_bank':$this->cheque_bank=$new_value;break;
case 'cheque_branch':$this->cheque_branch=$new_value;break;
case 'dd_no':$this->dd_no=$new_value;break;
case 'dd_date':$this->dd_date=$new_value;break;
case 'dd_bank':$this->dd_bank=$new_value;break;
case 'dd_branch':$this->dd_branch=$new_value;break;
case 'neft_no':$this->neft_no=$new_value;break;
case 'neft_date':$this->neft_date=$new_value;break;
case 'neft_bank':$this->neft_bank=$new_value;break;
case 'neft_branch':$this->neft_branch=$new_value;break;
case 'ecs_no':$this->ecs_no=$new_value;break;
case 'ecs_date':$this->ecs_date=$new_value;break;
case 'ecs_bank':$this->ecs_bank=$new_value;break;
case 'ecs_branch':$this->ecs_branch=$new_value;break;
case 'cash_paid_on':$this->cash_paid_on=$new_value;break;
case 'cash_receipt_no':$this->cash_receipt_no=$new_value;break;
case 'payment_cleared_on':$this->payment_cleared_on=$new_value;break;
case 'remarks':$this->remarks=$new_value;break;
case 'updated_date':$this->updated_date=$new_value;break;
case 'tax_percent_total_1_code':$this->tax_percent_total_1_code=$new_value;break;
case 'tax_percent_total_1_val':$this->tax_percent_total_1_val=$new_value;break;
case 'tax_percent_total_2_code':$this->tax_percent_total_2_code=$new_value;break;
case 'tax_percent_total_2_val':$this->tax_percent_total_2_val=$new_value;break;
case 'tax_percent_total_3_code':$this->tax_percent_total_3_code=$new_value;break;
case 'tax_percent_total_3_val':$this->tax_percent_total_3_val=$new_value;break;
case 'tax_percent_total_4_code':$this->tax_percent_total_4_code=$new_value;break;
case 'tax_percent_total_4_val':$this->tax_percent_total_4_val=$new_value;break;
case 'tax_percent_total_5_code':$this->tax_percent_total_5_code=$new_value;break;
case 'tax_percent_total_5_val':$this->tax_percent_total_5_val=$new_value;break;
case 'tax_percent_total_6_code':$this->tax_percent_total_6_code=$new_value;break;
case 'tax_percent_total_6_val':$this->tax_percent_total_6_val=$new_value;break;
case 'tax_percent_total_7_code':$this->tax_percent_total_7_code=$new_value;break;
case 'tax_percent_total_7_val':$this->tax_percent_total_7_val=$new_value;break;
case 'tax_percent_total_8_code':$this->tax_percent_total_8_code=$new_value;break;
case 'tax_percent_total_8_val':$this->tax_percent_total_8_val=$new_value;break;
case 'tax_percent_total_9_code':$this->tax_percent_total_9_code=$new_value;break;
case 'tax_percent_total_9_val':$this->tax_percent_total_9_val=$new_value;break;
case 'tax_percent_total_10_code':$this->tax_percent_total_10_code=$new_value;break;
case 'tax_percent_total_10_val':$this->tax_percent_total_10_val=$new_value;break;
}
}
public function get_value($variable_name)
{
$to_return="";
switch($variable_name)
{
case 'invoice_no':$to_return=$this->invoice_no;break;
case 'tin_no':$to_return=$this->tin_no;break;
case 'service_tax_no':$to_return=$this->service_tax_no;break;
case 'invoice_status':$to_return=$this->invoice_status;break;
case 'buyer':$to_return=$this->buyer;break;
case 'buyer_address':$to_return=$this->buyer_address;break;
case 'invoice_date':$to_return=$this->invoice_date;break;
case 'delivery_note':$to_return=$this->delivery_note;break;
case 'buyer_wo_number':$to_return=$this->buyer_wo_number;break;
case 'wo_date':$to_return=$this->wo_date;break;
case 'name_of_work':$to_return=$this->name_of_work;break;
case 'delivery_material':$to_return=$this->delivery_material;break;
case 'delivery_address':$to_return=$this->delivery_address;break;
case 'site_in':$to_return=$this->site_in;break;
case 'total_vat':$to_return=$this->total_vat;break;
case 'total_stax':$to_return=$this->total_stax;break;
case 'total_cst':$to_return=$this->total_cst;break;
case 'packing_and_forwarding':$to_return=$this->packing_and_forwarding;break;
case 'total_bill':$to_return=$this->total_bill;break;
case 'amount_in_words':$to_return=$this->amount_in_words;break;
case 'order_generated_by':$to_return=$this->order_generated_by;break;
case 'payment_terms':$to_return=$this->payment_terms;break;
case 'remarks':$to_return=$this->remarks;break;
case 'created_by':$to_return=$this->created_by;break;
case 'created_browser':$to_return=$this->created_browser;break;
case 'created_ip':$to_return=$this->created_ip;break;
case 'updated_by':$to_return=$this->updated_by;break;
case 'updated_browser':$to_return=$this->updated_browser;break;
case 'updated_ip':$to_return=$this->updated_ip;break;
case 'description':$to_return=$this->description;break;
case 'rate':$to_return=$this->rate;break;
case 'quantity':$to_return=$this->quantity;break;
case 'total_row':$to_return=$this->total_row;break;
case 'tax':$to_return=$this->tax;break;
case 'amount':$to_return=$this->amount;break;
case 'cr_to_account':$to_return=$this->cr_to_account;break;
case 'due_date':$to_return=$this->due_date;break;
case 'status':$to_return=$this->status;break;
case 'payment_mode':$to_return=$this->payment_mode;break;
case 'cheque_no':$to_return=$this->cheque_no;break;
case 'cheque_date':$to_return=$this->cheque_date;break;
case 'cheque_bank':$to_return=$this->cheque_bank;break;
case 'cheque_branch':$to_return=$this->cheque_branch;break;
case 'dd_no':$to_return=$this->dd_no;break;
case 'dd_date':$to_return=$this->dd_date;break;
case 'dd_bank':$to_return=$this->dd_bank;break;
case 'dd_branch':$to_return=$this->dd_branch;break;
case 'neft_no':$to_return=$this->neft_no;break;
case 'neft_date':$to_return=$this->neft_date;break;
case 'neft_bank':$to_return=$this->neft_bank;break;
case 'neft_branch':$to_return=$this->neft_branch;break;
case 'ecs_no':$to_return=$this->ecs_no;break;
case 'ecs_date':$to_return=$this->ecs_date;break;
case 'ecs_bank':$to_return=$this->ecs_bank;break;
case 'ecs_branch':$to_return=$this->ecs_branch;break;
case 'cash_paid_on':$to_return=$this->cash_paid_on;break;
case 'cash_receipt_no':$to_return=$this->cash_receipt_no;break;
case 'payment_cleared_on':$to_return=$this->payment_cleared_on;break;
case 'remarks':$to_return=$this->remarks;break;
case 'updated_date':$to_return=$this->updated_date;break;
}
return $to_return;
}
public function create_retail_invoice()
{
$branch=$this->branch;
$invoice_company_name=$this->invoice_company_name;
$invoice_header=$this->invoice_header;
$tin_no=$this->tin_no;
$service_tax_no=$this->service_tax_no;
$invoice_status=$this->invoice_status;
$buyer=$this->buyer;
$invoice_date=$this->invoice_date;
$delivery_note=$this->delivery_note;
$buyer_wo_number=$this->buyer_wo_number;
$wo_date=$this->wo_date;
$name_of_work=$this->name_of_work;
$delivery_material=$this->delivery_material;
$delivery_address=$this->delivery_address;
$site_in=$this->site_in;
$total_vat=$this->total_vat;
$total_stax=$this->total_stax;
$total_cst=$this->total_cst;
$tax_percent_total_1_code=$this->tax_percent_total_1_code;
$tax_percent_total_1_val=$this->tax_percent_total_1_val;
$tax_percent_total_2_code=$this->tax_percent_total_2_code;
$tax_percent_total_2_val=$this->tax_percent_total_2_val;
$tax_percent_total_3_code=$this->tax_percent_total_3_code;
$tax_percent_total_3_val=$this->tax_percent_total_3_val;
$tax_percent_total_4_code=$this->tax_percent_total_4_code;
$tax_percent_total_4_val=$this->tax_percent_total_4_val;
$tax_percent_total_5_code=$this->tax_percent_total_5_code;
$tax_percent_total_5_val=$this->tax_percent_total_5_val;
$tax_percent_total_6_code=$this->tax_percent_total_6_code;
$tax_percent_total_6_val=$this->tax_percent_total_6_val;
$tax_percent_total_7_code=$this->tax_percent_total_7_code;
$tax_percent_total_7_val=$this->tax_percent_total_7_val;
$tax_percent_total_8_code=$this->tax_percent_total_8_code;
$tax_percent_total_8_val=$this->tax_percent_total_8_val;
$tax_percent_total_9_code=$this->tax_percent_total_9_code;
$tax_percent_total_9_val=$this->tax_percent_total_9_val;
$tax_percent_total_10_code=$this->tax_percent_total_10_code;
$tax_percent_total_10_val=$this->tax_percent_total_10_val;
$packing_and_forwarding=$this->packing_and_forwarding;
$total_bill=$this->total_bill;
$amount_in_words=$this->amount_in_words;
$order_generated_by=$this->order_generated_by;
$payment_terms=$this->payment_terms;
$remarks=$this->remarks;
$created_by=$this->created_by;
$created_browser=$this->created_browser;
$created_ip=$this->created_ip;
$amount=$this->amount;
$cr_to_account=$this->cr_to_account;
$due_date=$this->due_date;
$status=$this->status;
$payment_mode=$this->payment_mode;
$cheque_no=$this->cheque_no;
$cheque_date=$this->cheque_date;
$cheque_bank=$this->cheque_bank;
$cheque_branch=$this->cheque_branch;
$dd_no=$this->dd_no;
$dd_date=$this->dd_date;
$dd_bank=$this->dd_bank;
$dd_branch=$this->dd_branch;
$neft_no=$this->neft_no;
$neft_date=$this->neft_date;
$neft_bank=$this->neft_bank;
$neft_branch=$this->neft_branch;
$ecs_no=$this->ecs_no;
$ecs_date=$this->ecs_date;
$ecs_bank=$this->ecs_bank;
$ecs_branch=$this->ecs_branch;
$cash_paid_on=$this->cash_paid_on;
$cash_receipt_no=$this->cash_receipt_no;
$payment_cleared_on=$this->payment_cleared_on;
$desc_array=$this->description;
$rate_array=$this->rate;
$quantity_array=$this->quantity;
$total_row_array=$this->total_row;
$tax_array=$this->tax;
$columns_array=array("invoice_status","buyer","invoice_date","delivery_note","buyer_wo_number","wo_date","name_of_work","delivery_material","delivery_address","site_in","total_vat","total_stax","total_cst","tax_code_1","tax_payable_1","tax_code_2","tax_payable_2","tax_code_3","tax_payable_3","tax_code_4","tax_payable_4","tax_code_5","tax_payable_5","tax_code_6","tax_payable_6","tax_code_7","tax_payable_7","tax_code_8","tax_payable_8","tax_code_9","tax_payable_9","tax_code_10","tax_payable_10","packing_and_forwarding","total_bill","amount_in_words","order_generated_by","payment_terms","invoice_company_name","invoice_header","invoice_tin_no","invoice_service_tax_no","branch","created_by","created_browser","created_ip");
$columns_array_2=array("invoice_no","amount","cr_to_account","due_date","status","payment_mode","cheque_no","cheque_date","cheque_bank","cheque_branch","dd_no","dd_date","dd_bank","dd_branch","neft_no","neft_date","neft_bank","neft_branch","ecs_no","ecs_date","ecs_bank","ecs_branch","cash_paid_on","cash_receipt_no","payment_cleared_on","remarks","created_by","created_browser","created_ip");
$columns_array_3=array("invoice_no","description","rate","quantity","total_row","tax","created_by","created_browser","created_ip");
$columns_array_4=array("invoice_no","remarks","created_by","created_browser","created_ip");
$table_name="pss_retail_invoices";
$table_name_2="pss_retail_invoices_payments";
$table_name_3="pss_retail_invoices_items";
$table_name_4="pss_retail_invoices_remarks";
$mysql_obj=new mysql_functions_class;
$mysql_obj->open_connection();
$values_array=array($invoice_status,$buyer,$invoice_date,$delivery_note,$buyer_wo_number,$wo_date,$name_of_work,$delivery_material,$delivery_address,$site_in,$total_vat,$total_stax,$total_cst,$tax_percent_total_1_code,$tax_percent_total_1_val,$tax_percent_total_2_code,$tax_percent_total_2_val,$tax_percent_total_3_code,$tax_percent_total_3_val,$tax_percent_total_4_code,$tax_percent_total_4_val,$tax_percent_total_5_code,$tax_percent_total_5_val,$tax_percent_total_6_code,$tax_percent_total_6_val,$tax_percent_total_7_code,$tax_percent_total_7_val,$tax_percent_total_8_code,$tax_percent_total_8_val,$tax_percent_total_9_code,$tax_percent_total_9_val,$tax_percent_total_10_code,$tax_percent_total_10_val,$packing_and_forwarding,$total_bill,$amount_in_words,$order_generated_by,$payment_terms,$invoice_company_name,$invoice_header,$tin_no,$service_tax_no,$branch,$created_by,$created_browser,$created_ip);
$mysql_obj->start_transaction();
$mysql_obj->insert_simple($columns_array,$values_array,$table_name);
$invoice_no=$mysql_obj->get_value("last_insert_id");
if($payment_terms!="credit")
{
$values_array=array($invoice_no,$amount,$cr_to_account,$due_date,$status,$payment_mode,$cheque_no,$cheque_date,$cheque_bank,$cheque_branch,$dd_no,$dd_date,$dd_bank,$dd_branch,$neft_no,$neft_date,$neft_bank,$neft_branch,$ecs_no,$ecs_date,$ecs_bank,$ecs_branch,$cash_paid_on,$cash_receipt_no,$payment_cleared_on,$remarks,$created_by,$created_browser,$created_ip);
$mysql_obj->insert_simple_for_transaction($columns_array_2,$values_array,$table_name_2);
}
if($remarks!="")
{
$values_array=array($invoice_no,$remarks,$created_by,$created_browser,$created_ip);
$mysql_obj->insert_simple_for_transaction($columns_array_4,$values_array,$table_name_4);
}
for($i=0;$i<count($desc_array);$i++)
{
$description=$desc_array[$i];
$rate=$rate_array[$i];
$quantity=$quantity_array[$i];
$total_row=$total_row_array[$i];
$tax=$tax_array[$i];
$values_array=array($invoice_no,$description,$rate,$quantity,$total_row,$tax,$created_by,$created_browser,$created_ip);
$mysql_obj->insert_simple_for_transaction($columns_array_3,$values_array,$table_name_3);
}
$mysql_obj->commit();
$mysql_obj->close_connection();
}
public function create_tax_invoice()
{
$branch=$this->branch;
$invoice_status=$this->invoice_status;
$buyer=$this->buyer;
$invoice_date=$this->invoice_date;
$delivery_note=$this->delivery_note;
$buyer_wo_number=$this->buyer_wo_number;
$wo_date=$this->wo_date;
$name_of_work=$this->name_of_work;
$delivery_material=$this->delivery_material;
$delivery_address=$this->delivery_address;
$site_in=$this->site_in;
$total_vat=$this->total_vat;
$total_stax=$this->total_stax;
$total_vat_payable=$this->total_vat_payable;
$total_stax_payable=$this->total_stax_payable;
$packing_and_forwarding=$this->packing_and_forwarding;
$total_bill=$this->total_bill;
$amount_in_words=$this->amount_in_words;
$order_generated_by=$this->order_generated_by;
$payment_terms=$this->payment_terms;
$remarks=$this->remarks;
$created_by=$this->created_by;
$created_browser=$this->created_browser;
$created_ip=$this->created_ip;
$amount=$this->amount;
$cr_to_account=$this->cr_to_account;
$due_date=$this->due_date;
$status=$this->status;
$payment_mode=$this->payment_mode;
$cheque_no=$this->cheque_no;
$cheque_date=$this->cheque_date;
$cheque_bank=$this->cheque_bank;
$cheque_branch=$this->cheque_branch;
$dd_no=$this->dd_no;
$dd_date=$this->dd_date;
$dd_bank=$this->dd_bank;
$dd_branch=$this->dd_branch;
$neft_no=$this->neft_no;
$neft_date=$this->neft_date;
$neft_bank=$this->neft_bank;
$neft_branch=$this->neft_branch;
$ecs_no=$this->ecs_no;
$ecs_date=$this->ecs_date;
$ecs_bank=$this->ecs_bank;
$ecs_branch=$this->ecs_branch;
$cash_paid_on=$this->cash_paid_on;
$cash_receipt_no=$this->cash_receipt_no;
$payment_cleared_on=$this->payment_cleared_on;
$desc_array=$this->description;
$rate_array=$this->rate;
$quantity_array=$this->quantity;
$total_row_array=$this->total_row;
$tax_array=$this->tax;
$columns_array=array("invoice_status","buyer","invoice_date","delivery_note","buyer_wo_number","wo_date","name_of_work","delivery_material","delivery_address","site_in","total_vat","total_stax","total_vat_payable","total_stax_payable","packing_and_forwarding","total_bill","amount_in_words","order_generated_by","payment_terms","branch","created_by","created_browser","created_ip");
$columns_array_2=array("invoice_no","amount","cr_to_account","due_date","status","payment_mode","cheque_no","cheque_date","cheque_bank","cheque_branch","dd_no","dd_date","dd_bank","dd_branch","neft_no","neft_date","neft_bank","neft_branch","ecs_no","ecs_date","ecs_bank","ecs_branch","cash_paid_on","cash_receipt_no","payment_cleared_on","remarks","created_by","created_browser","created_ip");
$columns_array_3=array("invoice_no","description","rate","quantity","total_row","tax","created_by","created_browser","created_ip");
$columns_array_4=array("invoice_no","remarks","created_by","created_browser","created_ip");
$table_name="pss_tax_invoices";
$table_name_2="pss_tax_invoices_payments";
$table_name_3="pss_tax_invoices_items";
$table_name_4="pss_tax_invoices_remarks";
$mysql_obj=new mysql_functions_class;
$mysql_obj->open_connection();
$values_array=array($invoice_status,$buyer,$invoice_date,$delivery_note,$buyer_wo_number,$wo_date,$name_of_work,$delivery_material,$delivery_address,$site_in,$total_vat,$total_stax,$total_vat_payable,$total_stax_payable,$packing_and_forwarding,$total_bill,$amount_in_words,$order_generated_by,$payment_terms,$branch,$created_by,$created_browser,$created_ip);
$mysql_obj->start_transaction();
$mysql_obj->insert_simple($columns_array,$values_array,$table_name);
$invoice_no=$mysql_obj->get_value("last_insert_id");
if($payment_terms!="credit")
{
$values_array=array($invoice_no,$amount,$cr_to_account,$due_date,$status,$payment_mode,$cheque_no,$cheque_date,$cheque_bank,$cheque_branch,$dd_no,$dd_date,$dd_bank,$dd_branch,$neft_no,$neft_date,$neft_bank,$neft_branch,$ecs_no,$ecs_date,$ecs_bank,$ecs_branch,$cash_paid_on,$cash_receipt_no,$payment_cleared_on,$remarks,$created_by,$created_browser,$created_ip);
$mysql_obj->insert_simple_for_transaction($columns_array_2,$values_array,$table_name_2);
}
if($remarks!="")
{
$values_array=array($invoice_no,$remarks,$created_by,$created_browser,$created_ip);
$mysql_obj->insert_simple_for_transaction($columns_array_4,$values_array,$table_name_4);
}
for($i=0;$i<count($desc_array);$i++)
{
$description=$desc_array[$i];
$rate=$rate_array[$i];
$quantity=$quantity_array[$i];
$total_row=$total_row_array[$i];
$tax=$tax_array[$i];
$values_array=array($invoice_no,$description,$rate,$quantity,$total_row,$tax,$created_by,$created_browser,$created_ip);
$mysql_obj->insert_simple_for_transaction($columns_array_3,$values_array,$table_name_3);
}
$mysql_obj->commit();
$mysql_obj->close_connection();
}
public function create_challan_invoice()
{
$branch=$this->branch;
$invoice_status=$this->invoice_status;
$buyer=$this->buyer;
$invoice_date=$this->invoice_date;
$delivery_note=$this->delivery_note;
$buyer_wo_number=$this->buyer_wo_number;
$wo_date=$this->wo_date;
$name_of_work=$this->name_of_work;
$delivery_material=$this->delivery_material;
$delivery_address=$this->delivery_address;
$site_in=$this->site_in;
$packing_and_forwarding=$this->packing_and_forwarding;
$total_bill=$this->total_bill;
$amount_in_words=$this->amount_in_words;
$order_generated_by=$this->order_generated_by;
$payment_terms=$this->payment_terms;
$remarks=$this->remarks;
$created_by=$this->created_by;
$created_browser=$this->created_browser;
$created_ip=$this->created_ip;
$amount=$this->amount;
$cr_to_account=$this->cr_to_account;
$due_date=$this->due_date;
$status=$this->status;
$payment_mode=$this->payment_mode;
$cheque_no=$this->cheque_no;
$cheque_date=$this->cheque_date;
$cheque_bank=$this->cheque_bank;
$cheque_branch=$this->cheque_branch;
$dd_no=$this->dd_no;
$dd_date=$this->dd_date;
$dd_bank=$this->dd_bank;
$dd_branch=$this->dd_branch;
$neft_no=$this->neft_no;
$neft_date=$this->neft_date;
$neft_bank=$this->neft_bank;
$neft_branch=$this->neft_branch;
$ecs_no=$this->ecs_no;
$ecs_date=$this->ecs_date;
$ecs_bank=$this->ecs_bank;
$ecs_branch=$this->ecs_branch;
$cash_paid_on=$this->cash_paid_on;
$cash_receipt_no=$this->cash_receipt_no;
$payment_cleared_on=$this->payment_cleared_on;
$desc_array=$this->description;
$rate_array=$this->rate;
$quantity_array=$this->quantity;
$total_row_array=$this->total_row;
$columns_array=array("invoice_status","buyer","invoice_date","delivery_note","buyer_wo_number","wo_date","name_of_work","delivery_material","delivery_address","site_in","packing_and_forwarding","total_bill","amount_in_words","order_generated_by","payment_terms","branch","created_by","created_browser","created_ip");
$columns_array_2=array("invoice_no","amount","cr_to_account","due_date","status","payment_mode","cheque_no","cheque_date","cheque_bank","cheque_branch","dd_no","dd_date","dd_bank","dd_branch","neft_no","neft_date","neft_bank","neft_branch","ecs_no","ecs_date","ecs_bank","ecs_branch","cash_paid_on","cash_receipt_no","payment_cleared_on","remarks","created_by","created_browser","created_ip");
$columns_array_3=array("invoice_no","description","rate","quantity","total_row","created_by","created_browser","created_ip");
$columns_array_4=array("invoice_no","remarks","created_by","created_browser","created_ip");
$table_name="pss_challan_invoices";
$table_name_2="pss_challan_invoices_payments";
$table_name_3="pss_challan_invoices_items";
$table_name_4="pss_challan_invoices_remarks";
$mysql_obj=new mysql_functions_class;
$mysql_obj->open_connection();
$values_array=array($invoice_status,$buyer,$invoice_date,$delivery_note,$buyer_wo_number,$wo_date,$name_of_work,$delivery_material,$delivery_address,$site_in,$packing_and_forwarding,$total_bill,$amount_in_words,$order_generated_by,$payment_terms,$branch,$created_by,$created_browser,$created_ip);
$mysql_obj->start_transaction();
$mysql_obj->insert_simple($columns_array,$values_array,$table_name);
$invoice_no=$mysql_obj->get_value("last_insert_id");
if($payment_terms!="credit")
{
$values_array=array($invoice_no,$amount,$cr_to_account,$due_date,$status,$payment_mode,$cheque_no,$cheque_date,$cheque_bank,$cheque_branch,$dd_no,$dd_date,$dd_bank,$dd_branch,$neft_no,$neft_date,$neft_bank,$neft_branch,$ecs_no,$ecs_date,$ecs_bank,$ecs_branch,$cash_paid_on,$cash_receipt_no,$payment_cleared_on,$remarks,$created_by,$created_browser,$created_ip);
$mysql_obj->insert_simple_for_transaction($columns_array_2,$values_array,$table_name_2);
}
if($remarks!="")
{
$values_array=array($invoice_no,$remarks,$created_by,$created_browser,$created_ip);
$mysql_obj->insert_simple_for_transaction($columns_array_4,$values_array,$table_name_4);
}
for($i=0;$i<count($desc_array);$i++)
{
$description=$desc_array[$i];
$rate=$rate_array[$i];
$quantity=$quantity_array[$i];
$total_row=$total_row_array[$i];
$values_array=array($invoice_no,$description,$rate,$quantity,$total_row,$created_by,$created_browser,$created_ip);
$mysql_obj->insert_simple_for_transaction($columns_array_3,$values_array,$table_name_3);
}
$mysql_obj->commit();
$mysql_obj->close_connection();
}
public function view_retail_invoice_details($to_view)
{
$branch=$this->branch;
$prepared_statement="SELECT a.*,b.name AS buyer_name,b.phone,b.email,b.address,b.tin_no,b.service_tax_no FROM pss_retail_invoices a INNER JOIN pss_cust_vend b ON b.table_id=a.buyer WHERE a.branch='$branch' AND a.table_id='$to_view'";
$mysql_obj=new mysql_functions_class;
$mysql_obj->open_connection();
$to_view=$mysql_obj->real_escape($to_view);
$res=$mysql_obj->simply_run_statement_passed($prepared_statement);
if($res->num_rows!=1)
{
$mysql_obj->close_connection();
echo("Error : Multiple values found...");
exit();
}
$detail=$res->fetch_assoc();
$dob=$detail['invoice_date'];
if($dob!="0000-00-00")
{
$date_obj = new DateTime($dob);
$dob=$date_obj->format('d-M-Y');
}
$this->invoice_date=$dob;
$this->invoice_status=$detail['invoice_status'];
$this->delivery_note=$detail['delivery_note'];
$this->buyer_wo_number=$detail['buyer_wo_number'];
$this->wo_date=$detail['wo_date'];
$this->name_of_work=$detail['name_of_work'];
$this->delivery_material=$detail['delivery_material'];
$this->delivery_address=$detail['delivery_address'];
$this->site_in=$detail['site_in'];
$this->buyer=$detail['buyer_name'];
$this->tin_no=$detail['tin_no'];
$this->service_tax_no=$detail['service_tax_no'];
$this->buyer_address=$detail['address'];
$this->total_vat=$detail['total_vat'];
$this->total_stax=$detail['total_stax'];
$this->total_vat_payable=$detail['total_vat_payable'];
$this->total_stax_payable=$detail['total_stax_payable'];
$this->packing_and_forwarding=$detail['packing_and_forwarding'];
$this->total_bill=$detail['total_bill'];
$this->amount_in_words=$detail['amount_in_words'];
$this->order_generated_by=$detail['order_generated_by'];
$order_by=$detail['order_generated_by'];
if($detail['order_generated_by']!="none")
{
$prepared_statement_2="SELECT name FROM pss_staff_ids_for_invoices WHERE id='$order_by'";
$res_2=$mysql_obj->simply_run_statement_passed($prepared_statement_2);
if($res_2->num_rows!=1)
{
$mysql_obj->close_connection();
echo("Error : Multiple values found...");
exit();
}
$detail_2=$res_2->fetch_assoc();
$this->order_generated_by=$detail_2['name'];
}
$this->payment_terms=$detail['payment_terms'];
$mysql_obj->close_connection();
}
public function view_retail_invoice_items_for_invoice($invoice_no)
{
$mysql_obj=new mysql_functions_class;
$mysql_obj->open_connection();
$invoice_no=$mysql_obj->real_escape($invoice_no);
$prepared_statement="SELECT a.*,b.item_name FROM pss_retail_invoices_items a INNER JOIN pss_items b ON b.item_code=a.description WHERE a.invoice_no='$invoice_no'";
$res=$mysql_obj->simply_run_statement_passed($prepared_statement);
$mysql_obj->close_connection();
$sno=1;
while($detail=$res->fetch_assoc())
{
echo("<tr>");
echo("<td>".$sno."</td>");
echo("<td>".$detail['item_name']."</td>");
echo("<td>".$detail['rate']."</td>");
echo("<td>".$detail['quantity']."</td>");
echo("<td>".$detail['total_row']."</td>");
echo("</tr>");
$sno++;
}
}
public function add_installment_retail_invoice()
{
$remarks=$this->remarks;
$created_by=$this->created_by;
$created_browser=$this->created_browser;
$created_ip=$this->created_ip;
$invoice_no=$this->invoice_no;
$amount=$this->amount;
$cr_to_account=$this->cr_to_account;
$due_date=$this->due_date;
$status=$this->status;
$payment_mode=$this->payment_mode;
$cheque_no=$this->cheque_no;
$cheque_date=$this->cheque_date;
$cheque_bank=$this->cheque_bank;
$cheque_branch=$this->cheque_branch;
$dd_no=$this->dd_no;
$dd_date=$this->dd_date;
$dd_bank=$this->dd_bank;
$dd_branch=$this->dd_branch;
$neft_no=$this->neft_no;
$neft_date=$this->neft_date;
$neft_bank=$this->neft_bank;
$neft_branch=$this->neft_branch;
$ecs_no=$this->ecs_no;
$ecs_date=$this->ecs_date;
$ecs_bank=$this->ecs_bank;
$ecs_branch=$this->ecs_branch;
$cash_paid_on=$this->cash_paid_on;
$cash_receipt_no=$this->cash_receipt_no;
$payment_cleared_on=$this->payment_cleared_on;
$columns_array_2=array("invoice_no","amount","cr_to_account","due_date","status","payment_mode","cheque_no","cheque_date","cheque_bank","cheque_branch","dd_no","dd_date","dd_bank","dd_branch","neft_no","neft_date","neft_bank","neft_branch","ecs_no","ecs_date","ecs_bank","ecs_branch","cash_paid_on","cash_receipt_no","payment_cleared_on","remarks","created_by","created_browser","created_ip");
$table_name_2="pss_retail_invoices_payments";
$mysql_obj=new mysql_functions_class;
$mysql_obj->open_connection();
$values_array=array($invoice_no,$amount,$cr_to_account,$due_date,$status,$payment_mode,$cheque_no,$cheque_date,$cheque_bank,$cheque_branch,$dd_no,$dd_date,$dd_bank,$dd_branch,$neft_no,$neft_date,$neft_bank,$neft_branch,$ecs_no,$ecs_date,$ecs_bank,$ecs_branch,$cash_paid_on,$cash_receipt_no,$payment_cleared_on,$remarks,$created_by,$created_browser,$created_ip);
$mysql_obj->start_transaction();
$mysql_obj->insert_simple($columns_array_2,$values_array,$table_name_2);
$this->update_retail_invoice_status_without_connection($invoice_no,$mysql_obj);
$mysql_obj->commit();
$mysql_obj->close_connection();
}
public function update_retail_invoice_status_without_connection($to_change,$mysql_obj)
{
$branch=$this->branch;
$to_change=$mysql_obj->real_escape($to_change);
$prepared_statement="SELECT total_bill FROM pss_retail_invoices WHERE table_id='$to_change'";
$res=$mysql_obj->simply_run_statement_passed($prepared_statement);
if($res->num_rows!=1)
{
$mysql_obj->close_connection();
echo("Error : Multiple values found...");
exit();
}
$detail=$res->fetch_assoc();
$total_bill=$detail['total_bill'];
$prepared_statement="SELECT SUM(amount) AS total FROM pss_retail_invoices_payments WHERE invoice_no='$to_change' AND status='paid'";
$res=$mysql_obj->simply_run_statement_passed($prepared_statement);
if($res->num_rows!=1)
{
$mysql_obj->close_connection();
echo("Error : Multiple values found...");
exit();
}
$detail=$res->fetch_assoc();
$total_paid=$detail['total'];
$status="undefined";
$prepared_statement="SELECT * FROM pss_retail_invoices_payments WHERE invoice_no='$to_change' AND status NOT IN('paid','pending')";
$res=$mysql_obj->simply_run_statement_passed($prepared_statement);
if($res->num_rows>0)
{
$status="progress";
}
if($total_paid>=$total_bill)
{
$prepared_statement="UPDATE pss_retail_invoices SET invoice_status='paid' WHERE table_id='$to_change' AND branch='$branch'";
$mysql_obj->simply_run_statement_passed($prepared_statement);
}
else if($status=="progress")
{
$prepared_statement="UPDATE pss_retail_invoices SET invoice_status='progress' WHERE table_id='$to_change' AND branch='$branch'";
$mysql_obj->simply_run_statement_passed($prepared_statement);
}
}
public function view_all_status_retail_invoices($invoice_status)
{
$branch=$this->branch;
$columns_array=array("invoice_status");
$table_name="pss_retail_invoices";
$conditions=" WHERE branch='$branch' ORDER BY invoice_status ";
$mysql_obj=new mysql_functions_class;
$mysql_obj->open_connection();
$res=$mysql_obj->select_simple($table_name,$columns_array,$conditions);
while($detail=$res->fetch_assoc())
{
echo("<option");
if($invoice_status==$detail['invoice_status'])
{
echo(" selected");
}
echo(">".$detail['invoice_status']."</option>");
}
$mysql_obj->close_connection();
}
public function view_all_payment_terms_retail_invoices($payment_terms)
{
$branch=$this->branch;
$columns_array=array("payment_terms");
$table_name="pss_retail_invoices";
$conditions=" WHERE branch='$branch' ORDER BY payment_terms ";
$mysql_obj=new mysql_functions_class;
$mysql_obj->open_connection();
$res=$mysql_obj->select_simple($table_name,$columns_array,$conditions);
while($detail=$res->fetch_assoc())
{
echo("<option");
if($payment_terms==$detail['payment_terms'])
{
echo(" selected");
}
echo(">".$detail['payment_terms']."</option>");
}
$mysql_obj->close_connection();
}
public function view_all_status_purchases_invoices($invoice_status)
{
$branch=$this->branch;
$columns_array=array("invoice_status");
$table_name="pss_inventories_purchase";
$conditions=" WHERE branch='$branch' ORDER BY invoice_status ";
$mysql_obj=new mysql_functions_class;
$mysql_obj->open_connection();
$res=$mysql_obj->select_simple($table_name,$columns_array,$conditions);
while($detail=$res->fetch_assoc())
{
echo("<option");
if($invoice_status==$detail['invoice_status'])
{
echo(" selected");
}
echo(">".$detail['invoice_status']."</option>");
}
$mysql_obj->close_connection();
}
public function view_all_payment_terms_purchase_invoices($payment_terms)
{
$branch=$this->branch;
$columns_array=array("payment_terms");
$table_name="pss_inventories_purchase";
$conditions=" WHERE branch='$branch' ORDER BY payment_terms ";
$mysql_obj=new mysql_functions_class;
$mysql_obj->open_connection();
$res=$mysql_obj->select_simple($table_name,$columns_array,$conditions);
while($detail=$res->fetch_assoc())
{
echo("<option");
if($payment_terms==$detail['payment_terms'])
{
echo(" selected");
}
echo(">".$detail['payment_terms']."</option>");
}
$mysql_obj->close_connection();
}
}
?>