+
diff --git a/application/config/routes.php b/application/config/routes.php index 588d97a8..3e1417b5 100644 --- a/application/config/routes.php +++ b/application/config/routes.php @@ -81,7 +81,6 @@ $route['loanreports'] = 'payslip/loadLoanReport'; - //<-----------Application Add Routes------------> $route['addNew'] = "user/addNew"; $route['addNewUser'] = "user/addNewUser"; @@ -205,6 +204,10 @@ $route['Stock'] = "storestatus/storeavailability"; $route['UpdatePOStatus'] = "servicepurchaseorder/UpdateServicePOStatus"; $route['ServicePOBilling'] = "servicepurchaseorder/viewServicePOReportForBilling"; +//<------------Cash book Routes--------------------> +$route['ViewIncomeExpense'] = "cashbook/incomeExpenseList"; +$route['addNewIncomeExpense'] = "cashbook/addNewIncomeExpenseLoad"; +$route['addIncomeExpense'] = "cashbook/addIncomeExpense"; //<-------------Reports page-----------------> $route['reportpending'] = "report/pending_report"; @@ -215,7 +218,9 @@ $route['Report_costcenter'] = "report/ccr"; $route['Report_Material_Supplier'] = "report/MM_Supplier"; $route['Report_Material_Item'] = "report/MM_Item"; $route['Report_Material_ReceiptValue'] = "report/MM_ReceiptValue"; - +$route['Report_purchase'] = "report/purchase"; +$route['Report_year_wise'] = "report/year_wise"; +$route['Report_supplier'] = "report/purchase_supplier"; // Company Information $route['companyview'] = 'companycontroller/companyview'; @@ -243,4 +248,4 @@ $route['editOlddepartment'] = "department/viewdepartment"; $route['editOlddepartment/(:num)'] = "department/viewdepartment/$1"; $route['editdepartment'] = "department/editdepartment"; /* End of file routes.php */ -/* Location: ./application/config/routes.php */ +/* Location: ./application/config/routes.php */ \ No newline at end of file diff --git a/application/controllers/cashbook.php b/application/controllers/cashbook.php new file mode 100755 index 00000000..a2c64b21 --- /dev/null +++ b/application/controllers/cashbook.php @@ -0,0 +1,364 @@ +load->model('cashbook_model'); + $this->isLoggedIn(); + $this->load->helper(array('form','url')); + $this->load->library('upload'); + + } + + function incomeExpenseList() + { + + $aid = $this->uri->segment(3); + $str = $this->uri->segment(4); + if(!empty($aid)){ + + if(!empty($str)) + { + //echo "PDF"; + $data['company'] = $this->cashbook_model->getCompany(); + + $data['data'] = $this->cashbook_model->getIncomeExpenseList($aid); + //$pic1 = $data['company'][0]->ProfilePic; + //echo $pic1; + //$pic = base_url().'uploads/images'.$pic1; + //echo $pic; + //die(); + $totalamt = $data['data'][0]->total; + $data['amtinwords'] = $this->convertNumber($totalamt); + $mpdf=new mPDF('utf-8','A4-P',7, 10,10, 10, 3, 0, 0, 0); + $mpdf->SetHTMLHeader($HtmlHeading); + $html = $this->load->view('cashbookpdf',$data,true); + $mpdf->SetDisplayMode('fullpage'); + $mpdf->setFooter($HTMLFooter . "Page {PAGENO} of {nb}"); + $mpdf->list_indent_first_level = 1; + $mpdf->setAutoTopMargin = 'stretch'; + $mpdf->setAutoBottomMargin = 'stretch'; + $mpdf->WriteHTML($html); + $filename = "cashbook.pdf"; + $mpdf->Output($filename,I); + } + else + { + + $data['data'] = $this->cashbook_model->getIncomeExpenseList($aid); + //print_r($data['dropdownvalues']);die(); + $this->global['pageTitle'] = 'Resico : Cash Book: View Income Expense '; + $this->loadViews("viewIndIncomeExpense", $this->global, $data , NULL); + + } + + }else{ + $data['list'] = $this->cashbook_model->getIncomeExpenseList(); + $this->global['pageTitle'] = 'Resico : Cash Book: Listing'; + + $this->loadViews("income_expense_list", $this->global, $data , NULL); + } + + + } + + function addNewIncomeExpenseLoad() + { + + $data['dropdownvalues'] = $this->cashbook_model->getAccounTypes(); + //print_r($data['dropdownvalues']);die(); + $this->global['pageTitle'] = 'Resico : Cash Book: Add New Income Expense '; + $this->loadViews("addnewIncomeExpense", $this->global, $data , NULL); + } + + + function addIncomeExpense() + { + //echo "welcome"; + //die(); + $accounttype = $this->input->post('myradio'); + if($accounttype == 1) + { + $accounttype = 'INCOME'; + } + else + { + $accounttype = 'EXPENSE'; + } + $accountcode = $this->input->post('accode'); + $date = $this->input->post('Date'); + $date = date_create($date);//,'Y-m-d'); + $date = date_format($date,'Y-m-d'); + $towhome = $this->input->post('towhome'); + + $gsttoggle = $this->input->post('gsttoggle'); + $invoiceno = null; + $merchantname = null; + $mergstno = null; + $hsn = null; + $beforegst = null; + $sgst = null; + $cgst = null; + $igst = null; + if(!empty($gsttoggle)) + { + $invoiceno = $this->input->post('Invoiceno'); + $merchantname = $this->input->post('merchant'); + $mergstno = $this->input->post('Merchantgst'); + $hsn = $this->input->post('hsn'); + $beforegst = $this->input->post('valuebeforegST'); + $sgst = $this->input->post('SGST'); + $cgst = $this->input->post('CGST'); + $igst = $this->input->post('IGST'); + } + + $totalamount = $this->input->post('totalamount'); + + $description = $this->input->post('description'); + if(empty($description)){$description = 'NA';} + $document = null; + + $fs = 0; + if(!empty($_FILES['myfile']['name'])) + { + //echo "FILE AVAILABLE"; + $config['file_name'] = $_FILES['myfile']['name']; + $config['upload_path'] = 'uploads/cashbook/'; + $path = $config['upload_path']; + //$filename = $config['file_name']; + $document = $path.$filename; + //echo $document; + $fs = $this->uploadFile(); + $document = $path.$fs; + + } + $created_by = $this->session->userdata('userId'); + $addincomexpense = array('type'=>$accounttype,'account_code'=>$accountcode,'date'=>$date,'towhom'=>$towhome,'invoice_no'=>$invoiceno,'merchant'=>$merchantname,'merchant_gst'=>$mergstno,'HSN'=>$hsn ,'value_before_gst'=>$beforegst,'sgst'=>$sgst,'cgst'=>$cgst,'igst'=>$igst,'total'=>$totalamount,'description'=>$description,'document'=>$document,'Created_By'=>$created_by); + $res = $this->cashbook_model->saveIncomeExpense($addincomexpense); + if( $res == 1 ){ + echo ""; + } + + } + + + function uploadFile() + { + + //echo "INSIDE UPLOAFD"; + + //$this->load->library('upload') + $pathinfo = pathinfo($_FILES['myfile']['name']); + $config['upload_path'] = 'uploads/cashbook/'; + $config['allowed_types'] = 'png|jpg|jpeg'; + $config['file_name'] = $_FILES['myfile']['name']; + // $config['overwrite'] = true; + + //Load upload library and initialize configuration + $this->load->library('upload',$config); + $this->upload->initialize($config); + + + if($this->upload->do_upload('myfile')) + { + $uploadData = $this->upload->data(); + $uploadfilename = $uploadData['file_name']; + return $uploadfilename; + + } + else + { + $error = array('error' => $this->upload->display_errors()); + $uploadfilename = ''; + print_r($error); + return 0; + } + + } + + function viewIE() + { + + $aid = $this->uri->segment(3); + + $data['data'] = $this->cashbook_model->getAccounutInfo(); + //print_r($data['dropdownvalues']);die(); + $this->global['pageTitle'] = 'Resico : Cash Book: View Income Expense '; + $this->loadViews("viewIndIncomeExpense", $this->global, $data , NULL); + + } + + public function index() + { + $this->global['pageTitle'] = 'Resico : Cashbook Details'; + $this->loadViews("cashbooklisting", $this->global, NULL , NULL); + + } + + public function cashbookList() + { + + + $this->load->model('cashbook_model'); + + $data['cashbook'] = $this->cashbook_model->Selectcash(); + + $this->global['pageTitle'] = 'Resico : Cashbook Listing'; + + $this->loadViews("cashbooklisting", $this->global, $data, NULL); + + } + + public function cashbookdtl() + { + + + $id = $this->input->post('id'); + $tablevalue = json_decode($id,true); + //print_r($tablevalue); + foreach($tablevalue as $tv) + { + if(!empty($tv['AccountCodeType'])){ + $acc_type = $tv['AccountCodeType']; + $acc_code = $tv['AccountCode']; + $acc_name = $tv['AccountName']; + $acc_desc = $tv['Description']; + $acc_state = $tv['Status']; + if(strtoupper($acc_state) == 'YES') + { + $acc_status = 1; + } + else{ + $acc_status = 0; + } + + + $dt = new DateTime('now', new DateTimeZone('Asia/Kolkata')); + $acc_createddt = $dt->format('Y-m-d H:i:s'); + + $cashbookdatas = array('type'=>$acc_type,'code'=>$acc_code,'name'=>$acc_name,'description'=>$acc_desc,'status'=>$acc_status,'created_on'=>$acc_createddt); + //print_r($cashbookdatas); + $result = $this->cashbook_model->Cashbook($cashbookdatas); + } + } + + + //redirect('cashbook/cashbookList','refresh'); + echo "Successfully Saved!"; + + + + + + } + + + public function convertNumber($amt){ + //echo $amt;die(); +$ShowPaise='0'; +$totalAmt=explode(".",$amt); + +$number = $totalAmt[0]; + $no = $number; + +if(!empty($totalAmt[1]) && $totalAmt[1]!=0){ +$point = $totalAmt[1]; + $ShowPaise='1'; +} + else{ +$point=0; + $ShowPaise='0'; +} + + + $hundred = null; + $digits_1 = strlen($no); + + $i = 0; + $str = array(); + $words = array('0' => '', '1' => 'One', '2' => 'Two', + '3' => 'three', '4' => 'Four', '5' => 'Five', '6' => 'Six', + '7' => 'seven', '8' => 'eight', '9' => 'nine', + '10' => 'ten', '11' => 'eleven', '12' => 'twelve', + '13' => 'thirteen', '14' => 'fourteen', + '15' => 'fifteen', '16' => 'sixteen', '17' => 'seventeen', + '18' => 'eighteen', '19' =>'nineteen', '20' => 'twenty', + '30' => 'thirty', '40' => 'forty', '50' => 'fifty', + '60' => 'sixty', '70' => 'seventy', + '80' => 'eighty', '90' => 'ninety','06'=>'Zero Six','01'=>'Zero One','02'=>'Zero Two' + ,'03'=>'Zero Three','04'=>'Zero Four','05'=>'Zero Five','07'=>'Zero Seven','08'=>'Zero Eight','09'=>'Zero Nine'); + $words1 = array('2' => 'twenty', + '3' => 'thirty', '4' => 'fourty', + '5' => 'fifty', '6' => 'sixty', '7' => 'seventy', + '8' => 'eighty', '9' =>'ninty'); + $words12 = array('11' => 'eleven', + '12' => 'twelve', '13' => 'thirteen', '14' => 'fourteen', + '15' => 'fifteen', '16' => 'sixteen', '17' => 'seventeen', + '18' => 'eighteen', '19' =>'nineteen', '20' => 'twenty',); + $digits = array('', 'hundred', 'thousand', 'lakh', 'crore'); + while ($i < $digits_1) { + $divider = ($i == 2) ? 10 : 100; + $number = floor($no % $divider); + $no = floor($no / $divider); + $i += ($divider == 10) ? 1 : 2; + if ($number) { + $plural = (($counter = count($str)) && $number > 1) ? 's' : null; + //print_r($plural); + $hundred = ($counter == 1 && $str[0]) ? ' and ' : null; + //print_r($hundred); + $str [] = ($number < 21) ? $words[$number] . + " " . $digits[$counter] . $plural . " " . $hundred + : + $words[floor($number / 10) * 10] + . " " . $words[$number % 10] . " " + . $digits[$counter] . $plural . " " . $hundred; + } else $str[] = null; + } + $str = array_reverse($str); + $result = implode('', $str); + if($point>=1 && $point<=10) + { + $points = ($point) ? + " " . $words[$point] : " "; + } + else if($point>=11 && $point<=20) + { + $points = ($point) ? + " " . $words12[$point] : " "; + } + else + { + $points = ($point) ? + " " . $words1[$point / 10] . " " . + $words[$point = $point % 10] : ''; + } + +if($ShowPaise=='0'){ + +$amountInWords = "Rupees " . $result." Only"; +} +else{ + +$amountInWords = "Rupees " . $result ." Paise ". $points." Only"; +} + + + return $amountInWords; + } + +} +?> \ No newline at end of file diff --git a/application/models/cashbook_model.php b/application/models/cashbook_model.php new file mode 100755 index 00000000..3ef6f47d --- /dev/null +++ b/application/models/cashbook_model.php @@ -0,0 +1,104 @@ +db->where('status',1); + $r = $this->db->get('t_accountcode'); + return $r->result(); + + } + + function saveIncomeExpense($data) + { + $this->db->insert('t_income_expense',$data); + $r = $this->db->affected_rows(); + return $r; + } + + function getIncomeExpenseList($i="") + { + $this->db->select('t_accountcode.name,T_Employee_Details.FirstName,T_Employee_Details.LastName,t_income_expense.*'); + $this->db->from('t_income_expense'); + $this->db->join('t_accountcode','t_income_expense.account_code=t_accountcode.code'); + $this->db->join('tbl_users','t_income_expense.Created_By=tbl_users.userId'); + $this->db->join('T_Employee_Details','tbl_users.EmpID=T_Employee_Details.EmpID'); + + if(!empty($i)) + { + $this->db->where('t_income_expense.id',$i); + } + $r = $this->db->get(); + return $r->result(); + } + + function getCompany() + { + $r = $this->db->get('T_Company_Details'); + return $r->result(); + + + } + + function getAccounutInfo($i) + { + $this->db->select('t_accountcode.name,t_income_expense.*'); + $this->db->from('t_income_expense'); + $this->db->join('t_accountcode','t_income_expense.account_code=t_accountcode.code'); + //$this->db->where('t_income_expense.id') + $r = $this->db->get(); + return $r->result(); + + } + + function Selectcash() + { + $this->db->select('*'); + $this->db->from('t_accountcode'); + $query = $this->db->get(); + $result = $query->result(); + return $result; + + } + + function Cashbook($cashbookdatas) + { + $code=$cashbookdatas['code']; + $type=$cashbookdatas['type']; + + $count=0; + + $this->db->select('count(*) as count'); + $this->db->from('t_accountcode'); + $this->db->where('type',$type); + $this->db->where('code',$code); + + $isExits = $this->db->get(); + $res = $isExits->result_array(); + + + if(!empty($res)) + { + $count = $res[0]['count']; + } + + + if($count == 0 )//for cashbook_insert + { + $cbi = $this->db->insert('t_accountcode', $cashbookdatas); + return $cbi; + } + elseif($count == 1)//for cashbook_update + { + $this->db->where('code',$code); + $cbu = $this->db->update('t_accountcode',$cashbookdatas); + return $cbu; + } + + } + +} + +?> \ No newline at end of file diff --git a/application/views/addnewIncomeExpense.php b/application/views/addnewIncomeExpense.php new file mode 100755 index 00000000..13c156aa --- /dev/null +++ b/application/views/addnewIncomeExpense.php @@ -0,0 +1,468 @@ + + + + +
+ CompanyName;?>Address;?> Mobile AlternateContactNumber;?> E-mail EmailAddress;?> GSTIN : GSTNO;?> + |
+|||||
CASH VOUCHER |
+|||||
| Voucher Number | +id;?> | +
Rs total;?>Amount |
+
+|||
| Date | +date),'d-m-Y');?> | +||||
| + | towhom;?> | +||||
| Amount (In Words) | ++ | ||||
|
+ Remarks + + |
+description;?> | +||||
| + | + | + | + | Prepared By | +FirstName.' '.$data[0]->LastName;?> | +
| Checked By | ++ | ||||
| Verified By | ++ | ||||
|
+ + + Authorized Signature + |
+
+
+ + + Receiver's Signature + |
+||||
| Note : Above Rs.750/- With Revenue Stamp & Signature | +|||||
| Account Type | +DATE | +Account Name | +Amount | +Details | + +
|---|---|---|---|---|
| id.'">'.$l->type.'';?> | date),'d-m-Y');?> | name;?> | total;?> | description;?> |
Date : | date)){echo date_format(date_create($data[0]->date),'d-m-Y');}?> | |
| towhom)){echo $data[0]->towhom;}?> | ||
Invoice No : | invoice_no)){echo $data[0]->invoice_no;}?> | |
Merchant Name : | merchant)){echo $data[0]->merchant;}?> | |
Merchant GST No : | merchant_gst)){echo $data[0]->merchant_gst;}?> | |
HSN/SAC No : | HSN)){echo $data[0]->HSN;}?> | |
Value Before GST : | value_before_gst)){echo $data[0]->value_before_gst;}?> | |
SGST : | sgst)){echo $data[0]->sgst;}?> | |
CGST : | cgst)){echo $data[0]->cgst;}?> | |
IGST : | igst)){echo $data[0]->igst;}?> | |
Total Amount : | total)){echo $data[0]->total;}?> | |
Description : | description)){echo $data[0]->description;}?> |