Created
October 6, 2024 12:12
-
-
Save rasulsh/b491e500f065af9f56279229d23e40fb to your computer and use it in GitHub Desktop.
Revisions
-
rasulsh created this gist
Oct 6, 2024 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,33 @@ public function addDocument($data = array()) { $user_id = $this->user->getId(); $user_selected_date = call_function($this->language->get('function_jtg'), $this->db->escape($data['user_selected_date'])); $document_note = strip_tags(trim($data['document_note'])); $this->db->query("INSERT INTO `" . DB_PREFIX . "finance_document` SET `user_id` = '" . $this->db->escape($user_id) . "', `user_selected_date` = '" . $this->db->escape($user_selected_date) . "', `document_note` = '" . $this->db->escape($document_note) . "'"); $document_id = $this->db->getLastId(); $values = []; foreach ($data['document_items'] as $item) { // عدد مثبت بستانکار // عدد منفی بدهکار $value = 0; if (empty($item['debtor'])) { $value = $item['creditor']; } else { $value = $item['debtor'] * (-1); } $item_note = strip_tags(trim($item['item_note'])); $values[] = "('" . $document_id . "', '" . $this->db->escape($item['contact_id']) . "', '" . $this->db->escape($value) . "', '" . $this->db->escape($item_note) . "')"; } if (!empty($values)) { $sql = "INSERT INTO `" . DB_PREFIX . "finance_document_item` (`document_id`, `contact_id`, `value`, `item_note`) VALUES " . implode(", ", $values); $this->db->query($sql); } }