Esempio n. 1
0
 public function ajax_add()
 {
     //$this->_validate();
     $dibayar = str_replace(',', '', $this->input->post('dibayar'));
     $kurensi = $this->input->post('kurensi');
     $list_id = $this->input->post('inv');
     $saldo = str_replace(',', '', $this->input->post('saldo'));
     $data = array('list_id' => $list_id, 'no' => $this->input->post('no'), 'coa_id' => $this->input->post('coa_id'), 'tgl_dibayar' => date('Y-m-d', strtotime($this->input->post('tgl_dibayar'))), 'dibayar' => $dibayar, 'catatan' => $this->input->post('catatan'), 'created_by' => sessId(), 'created_on' => dateNow());
     $insert = $this->main->save($data);
     $terbayar = getValue('terbayar', 'purchase_hutang_list', array('id' => 'where/' . $list_id));
     $terbayar = $terbayar + $dibayar;
     $status = $saldo > 0 ? 2 : 3;
     $data_list = array('terbayar' => $terbayar, 'saldo' => $saldo, 'status_hutang_id' => $status, 'edited_by' => sessId(), 'edited_on' => dateNow());
     $this->db->where('id', $list_id)->update('purchase_hutang_list', $data_list);
     rekening('purchase_hutang', $insert, $data['coa_id'], 'out', $data['dibayar'], 0, $kurensi);
     echo json_encode(array("status" => TRUE));
 }
Esempio n. 2
0
 function add()
 {
     permissionUser();
     //print_mz($this->input->post());
     $webmaster_id = $this->session->userdata('user_id');
     $id = $this->input->post('id');
     $GetColumns = GetColumns($this->file_name);
     foreach ($GetColumns as $r) {
         $data[$r['Field']] = $this->input->post($r['Field']);
         $data[$r['Field'] . "_temp"] = $this->input->post($r['Field'] . "_temp");
         if (!$data[$r['Field']] && !$data[$r['Field'] . "_temp"]) {
             unset($data[$r['Field']]);
         }
         unset($data[$r['Field'] . "_temp"]);
     }
     //konversi mata uang
     $data['amount'] = str_replace(',', '', $data['amount']);
     $data['kurs'] = str_replace(',', '', $data['kurs']);
     if ($data['kurs'] == '' || $data['kurs'] == NULL) {
         $data['kurs'] == 1;
     }
     $data['rv'] = $data['amount'];
     if ($data['currency'] == '1') {
         $data['amount'] = $data['rv'] * $data['kurs'];
     } elseif ($data['currency'] == '2') {
         $data['amount'] = $data['rv'] * $data['kurs'];
     }
     //$data['rv']=$data['amount'];
     ///$data['kurs']=getkurs($data['rc']);
     //$data['amount']=$data['rv']*$data['kurs'];
     //--------konversi mata uang
     /* if(!$this->input->post('global')){$data['global']='N';}
     		else{$data['global']='Y';}  */
     if ($id > 0) {
         /* if(!$this->input->post('password')){unset($data['password']);}
         			else{$data['password']=md5($this->config->item('encryption_key').$this->input->post("password"));} */
         $data['modify_by'] = $webmaster_id;
         $data['modify_on'] = date("Y-m-d");
         $this->db->where("id", $id);
         $this->db->update($this->file_name, $data);
         $this->session->set_flashdata("message", 'Sukses diedit');
     } else {
         //$data['number']=generatenumbering('petty'.$webmaster_id);			//if($this->input->post('password')){$data['password']=md5($this->config->item('encryption_key').$this->input->post("password"));}
         //if(!$this->input->post('avatar')){$data['avatar']='default.png';}
         $data['created_by'] = $webmaster_id;
         $data['created_on'] = date("Y-m-d H:i:s");
         $this->db->insert($this->file_name, $data);
         $id = $this->db->insert_id();
         //addnumbering('petty'.$webmaster_id);
         $this->session->set_flashdata("message", 'Sukses ditambahkan');
     }
     rekening('cash_transfer', $id, $data['dari'], 'out', $data['amount'], $data['kurs'], $data['currency']);
     rekening('cash_transfer', $id, $data['ke'], 'in', $data['amount'], $data['kurs'], $data['currency']);
     redirect($this->module . '/' . $this->file_name, 'refresh');
 }
Esempio n. 3
0
 function add()
 {
     permissionUser();
     //print_mz($this->input->post());
     $webmaster_id = $this->session->userdata('user_id');
     $id = $this->input->post('id');
     $list = array('akun' => $this->input->post('akun'), 'amount' => $this->input->post('amounts'), 'remark' => $this->input->post('remark'));
     $data = array('save_type' => $this->input->post('save_type'), 'number' => $this->input->post('number'), 'dates' => $this->input->post('dates'), 'amount' => str_replace(',', '', $this->input->post('amount')), 'ref' => $this->input->post('ref'), 'coa' => $this->input->post('coa'), 'from' => $this->input->post('from'), 'memo' => $this->input->post('memo'), 'create_date' => date("Y-m-d"), 'create_user_id' => sessId());
     if ($id > 0) {
         $this->db->where('id', $id);
         $this->db->update('cash_petty', $data);
         $insert_id = $id;
         $this->db->query("DELETE FROM cash_petty_detail WHERE id_petty='{$id}'");
     } else {
         $this->db->insert('cash_petty', $data);
         $insert_id = $this->db->insert_id();
     }
     $sisaan = 0;
     hapus_rekening('cash_petty', $insert_id);
     rekening('cash_petty', $insert_id, $data['coa'], $data['save_type'], $data['amount'], 0, 0);
     for ($i = 0; $i < sizeof($list['akun']); $i++) {
         if ($list['akun'][$i] > 0) {
             if ($data['save_type'] == 'in') {
                 $credit = $list['amount'][$i];
                 $debit = 0;
             } elseif ($data['save_type'] == 'out') {
                 $debit = $list['amount'][$i];
                 $credit = 0;
             }
             $data2 = array('id_petty' => $insert_id, 'akun' => $list['akun'][$i], 'amount' => str_replace(',', '', $list['amount'][$i]), 'kredit' => str_replace(',', '', $credit), 'debit' => str_replace(',', '', $debit), 'remark' => $list['remark'][$i]);
             $this->db->insert('cash_petty_detail', $data2);
             rekening('cash_petty', $insert_id, $data2['akun'], $data['save_type'], $data2['amount'], 0, 0);
         }
         //$sisaan=+$sisa;
         //	masukstok($this->input->post('gudang_id'),$list['kode_barang'][$i],str_replace(',', '', $list['jumlah'][$i]));
         //$this->send_notification($insert_id);
     }
     //echo $sisaan;
     //	if($sisaan==0){$this->db->query("UPDATE purchase_order SET is_closed=1 WHERE id='".$this->input->post('ref_id')."'");}
     redirect($this->module . '/' . $this->file_name, 'refresh');
 }