示例#1
1
 public function Execute()
 {
     $conn = \ZCL\DB\DB::getConnect();
     $store_id = $this->headerdata['store_id'];
     $item = \ZippyERP\ERP\Entity\Item::getSumItem();
     $stock = \ZippyERP\ERP\Entity\Stock::getStock($store_id, $item->item_id, 1, true);
     $discont = 0;
     //скидки  704  счет
     $date = new Carbon();
     $date->setTimestamp($this->document_date);
     $end = $date->endOfMonth()->getTimestamp();
     $begin = $date->startOfMonth()->getTimestamp();
     $sql = " select coalesce(abs(sum(amount)),0) from erp_account_subconto where amount < 0  and account_id=285 and  extcode  = {$store_id} and  document_date  <= " . $conn->DBDate($end);
     $tm = $conn->GetOne($sql);
     //торговая  наценка на  конец периода
     //остатки на  конец периода
     $sql = " select coalesce(sum(quantity),0) AS quantity,coalesce(price,0) as price  from erp_account_subconto sc join erp_store_stock  st on sc.stock_id = st.stock_id where    store_id = {$store_id} and date(document_date) <= " . $conn->DBDate($end);
     $row = $conn->GetRow($sql);
     $ost = $row['quantity'] / 1000;
     $ost = $ost * $row['price'];
     if ($ost == 0) {
         return;
     }
     //выручка
     $sql = " select coalesce(abs(sum(amount)),0) from erp_account_subconto where amount < 0  and account_id=702 and  extcode  = {$store_id} and date(document_date) <= " . $conn->DBDate($end) . " and date(document_date) >= " . $conn->DBDate($begin);
     $saled = $conn->GetOne($sql);
     //выручка сданная в кассу
     $k = ($tm - $discont) / ($ost - $discont);
     $sb = (1 - $k) * $saled;
     //себестоимость
     // списываем  наценку
     Entry::AddEntry("285", "282", $saled - $sb, $this->document_id, $this->document_date);
     // себестоимость реализации
     Entry::AddEntry("902", "282", $sb, $this->document_id, $this->document_date);
     $item = \ZippyERP\ERP\Entity\Item::getSumItem();
     $stockto = \ZippyERP\ERP\Entity\Stock::getStock($store_id, $item->item_id, 1, true);
     $sc = new SubConto($this, 282, 0 - $saled);
     $sc->setStock($stockto->stock_id);
     $sc->setQuantity(0 - $saled * 1000);
     //цена  единицы  товара - 1 копейка.
     $sc->save();
     // НДС
     $nds = H::nds(true);
     Entry::AddEntry("702", "641", $saled * $nds, $this->document_id, $this->document_date);
     return true;
 }
示例#2
0
 public function savedocOnClick($sender)
 {
     $store = Store::load($this->docform->store->getValue());
     if ($store == false) {
         $this->setError("Не  выбран  магазин");
         return;
     }
     $this->_doc->document_number = $this->docform->document_number->getText();
     $this->_doc->document_date = $this->docform->document_date->getDate();
     $this->_doc->headerdata['store_id'] = $store->store_id;
     $this->_doc->headerdata['storename'] = $store->storename;
     $isEdited = $this->_doc->document_id > 0;
     $conn = \ZCL\DB\DB::getConnect();
     $conn->BeginTrans();
     try {
         $this->_doc->save();
         if ($sender->id == 'execdoc') {
             $this->_doc->updateStatus(Document::STATE_EXECUTED);
         } else {
             $this->_doc->updateStatus($isEdited ? Document::STATE_EDITED : Document::STATE_NEW);
         }
         $conn->CommitTrans();
         App::RedirectBack();
     } catch (\ZippyERP\System\Exception $ee) {
         $conn->RollbackTrans();
         $this->setError($ee->message);
     } catch (\Exception $ee) {
         $conn->RollbackTrans();
         throw new \Exception($ee->message);
     }
 }
示例#3
0
 public function Execute()
 {
     $conn = \ZCL\DB\DB::getConnect();
     $conn->StartTrans();
     $total = $this->headerdata['total'];
     $customer_id = $this->headerdata["customer"];
     // \ZippyERP\ERP\Entity\Customer::AddActivity($customer_id, 0 - $total, $this->document_id);
     if ($this->headerdata['cash'] == true) {
         $cash = MoneyFund::getCash();
         \ZippyERP\ERP\Entity\Entry::AddEntry("30", "36", $total, $this->document_id, $cash->id, $customer_id);
         $sc = new SubConto($this, 36, 0 - $total);
         $sc->setCustomer($this->headerdata["customer"]);
         $sc->save();
         $sc = new SubConto($this, 30, $total);
         $sc->setMoneyfund($cash->id);
         // $sc->save();
     }
     if ($this->headerdata['totalnds'] > 0) {
         Entry::AddEntry("703", "643", $this->headerdata['totalnds'], $this->document_id, $this->document_date);
     }
     Entry::AddEntry("36", "703", $total, $this->document_id, $this->document_date);
     $sc = new SubConto($this, 36, $total);
     $sc->setCustomer($this->headerdata["customer"]);
     $sc->save();
     $conn->CompleteTrans();
     return true;
 }
示例#4
0
 public function submitOnClick($sender)
 {
     if ($this->docform->customer->getValue() == 0) {
         $this->setError("Не выюран контрагент");
         return false;
     }
     $this->_doc->amount = 100 * $this->docform->amount->getText();
     $this->_doc->document_number = $this->docform->document_number->getText();
     $this->_doc->document_date = $this->docform->created->getDate();
     $this->_doc->headerdata = array('customer' => $this->docform->customer->getValue(), 'description' => $this->docform->description->getText(), 'startdate' => $this->docform->startdate->getDate(), 'enddate' => $this->docform->enddate->getDate());
     $this->_doc->detaildata = array();
     $this->_doc->datatag = $this->docform->customer->getValue();
     $isEdited = $this->_doc->document_id > 0;
     $conn = \ZCL\DB\DB::getConnect();
     $conn->BeginTrans();
     try {
         $this->_doc->save();
         if ($sender->id == 'execdoc') {
             $this->_doc->updateStatus(Document::STATE_EXECUTED);
         } else {
             $this->_doc->updateStatus($isEdited ? Document::STATE_EDITED : Document::STATE_NEW);
         }
         $conn->CommitTrans();
         App::RedirectBack();
     } catch (\ZippyERP\System\Exception $ee) {
         $conn->RollbackTrans();
         $this->setError($ee->message);
     } catch (\Exception $ee) {
         $conn->RollbackTrans();
         throw new \Exception($ee->message);
     }
 }
示例#5
0
文件: price.php 项目: Niqpue/zippyerp
 public function All()
 {
     $conn = \ZCL\DB\DB::getConnect();
     $groups = array();
     $rs = $conn->Execute('select distinct *  from  erp_item_group where  group_id in (select  group_id  from  erp_item where  price  > 0)  order  by  group_name');
     foreach ($rs as $row) {
         $groups[$row['group_id']] = $row['group_name'];
     }
     $xml = "<price>";
     foreach ($groups as $id => $name) {
         $xml .= "<group>";
         $xml .= "<name><![CDATA[{$name}]]></name>";
         $rs = $conn->Execute("select *  from  erp_item_view where  group_id ={$id} order  by  itemname");
         foreach ($rs as $row) {
             $price = number_format($row['price'] / 100, 2, '.', "");
             $xml .= "<item>";
             $xml .= "<name><![CDATA[{$row['itemname']}]]></name>";
             $xml .= "<price>{$price}</price>";
             $xml .= "<measure>{$row['measure_name']}</measure>";
             $xml .= "<description><![CDATA[{$row['description']}]]></description>";
             $xml .= "</item>";
         }
         $xml .= "</group>";
     }
     return $xml . "</price>";
 }
示例#6
0
 public function Execute()
 {
     $conn = \ZCL\DB\DB::getConnect();
     $conn->StartTrans();
     $employee_id = $this->headerdata["employee"];
     $expensetype = $this->headerdata['expensetype'];
     if ($expensetype == 201 || $expensetype == 22 || $expensetype == 281) {
         foreach ($this->detaildata as $value) {
             //поиск  записи  о  товаре   на складе
             $stock = \ZippyERP\ERP\Entity\Stock::getStock($this->headerdata['store'], $value['item_id'], $value['price'], true);
             $sc = new SubConto($this, $expensetype, $value['quantity'] / 1000 * $stock->price);
             $sc->setStock($stock->stock_id);
             $sc->setQuantity($value['quantity']);
             $sc->save();
         }
         Entry::AddEntry($expensetype, "372", $this->headerdata['total'] - $this->headerdata['totalnds'], $this->document_id, $this->document_date);
         //налоговый кредит
         if ($this->headerdata['totalnds'] > 0) {
             Entry::AddEntry("644", "372", $this->headerdata['totalnds'], $this->document_id, $this->document_date);
         }
     } else {
         Entry::AddEntry($expensetype, "372", $this->headerdata["expenseamount"], $this->document_id, $this->document_date);
         $sc = new SubConto($this, 372, 0 - $this->headerdata["expenseamount"]);
         $sc->setEmployee($employee_id);
         $sc->save();
     }
     $conn->CompleteTrans();
     return true;
 }
示例#7
0
文件: item.php 项目: Niqpue/zippyerp
 /**
  * Количество на оптовом складе на  дату
  *
  * @param mixed $item_id
  * @param mixed $date
  *
  */
 public static function getQuantity($item_id, $date)
 {
     $conn = \ZCL\DB\DB::getConnect();
     $where = "   stock_id IN( select stock_id from erp_store_stock st join erp_store sr on st.store_id = sr.store_id  where item_id= {$item_id} and store_type = " . Store::STORE_TYPE_OPT . " )  and date(document_date) <= " . $conn->DBDate($date);
     $sql = " select coalesce(sum(quantity),0) AS quantity  from erp_account_subconto  where " . $where;
     return $conn->GetOne($sql);
 }
示例#8
0
 /**
  * Сохраняет  спписок  ролей для юзера
  * 
  */
 public static function saveRoles($user_id, $roles)
 {
     $conn = \ZCL\DB\DB::getConnect();
     $conn->Execute('delete from system_user_role  where  user_id = ' . $user_id);
     foreach ($roles as $role_id) {
         $conn->Execute('insert into system_user_role (user_id,role_id) values(' . $user_id . ',' . $role_id . ')');
     }
 }
示例#9
0
 /**
  * Записывает набор  параметров  по имени набора
  * 
  * @param mixed $group
  * @param mixed $options
  */
 public static function setOptions($group, $options)
 {
     $options = serialize($options);
     $conn = \ZCL\DB\DB::getConnect();
     $conn->Execute(" delete from system_options where  optname='{$group}' ");
     $conn->Execute(" insert into system_options (optname,optvalue) values ('{$group}'," . $conn->qstr($options) . " ) ");
     self::$_options[$group] = $options;
 }
示例#10
0
文件: acl.php 项目: Niqpue/zippyerp
 public static function updateRoleAccess($meta_id, $rows)
 {
     $conn = \ZCL\DB\DB::getConnect();
     $conn->Execute("delete from erp_metadata_access where metadata_id ={$meta_id} ");
     foreach ($rows as $row) {
         $item = $row->getDataItem();
         $conn->Execute("insert  into erp_metadata_access (metadata_id,role_id,viewacc,editacc,deleteacc,execacc) values ({$meta_id},{$item->role_id}," . ($item->viewacc ? 1 : 0) . "," . ($item->editacc ? 1 : 0) . "," . ($item->deleteacc ? 1 : 0) . "," . ($item->execacc ? 1 : 0) . ") ");
     }
 }
示例#11
0
文件: stock.php 项目: Niqpue/zippyerp
 /**
  * Количество зарезервинование  и  ожидаемое после  даты
  *
  * @param mixed $stock_id
  * @param mixed $date
  * @param mixed $acc Синтетический счет
  * @return Массив с  двумя  значениями 'r'  и 'w'
  */
 public static function getQuantityFuture($stock_id, $date, $acc = 0)
 {
     $conn = \ZCL\DB\DB::getConnect();
     $where = "    stock_id = {$stock_id} and date(document_date) > " . $conn->DBDate($date);
     if ($acc > 0) {
         $where = $where . " and account_id= " . $acc;
     }
     $sql = " select coalesce(sum(case  when  quantity > 0 then quantity else 0 end ),0) as  w,  coalesce(sum(case  when  quantity < 0 then 0-quantity else 0 end ),0) as  r  from erp_account_subconto  where  " . $where;
     return $conn->GetRow($sql);
 }
示例#12
0
 public function Execute()
 {
     $conn = \ZCL\DB\DB::getConnect();
     $conn->StartTrans();
     $types = array();
     //аналитика
     foreach ($this->detaildata as $item) {
         $stock = \ZippyERP\ERP\Entity\Stock::getStock($this->headerdata['store'], $item['item_id'], $item['partion'], true);
         $sc = new SubConto($this, $item['type'], 0 - $item['partion'] * ($item['quantity'] / 1000));
         $sc->setStock($stock->stock_id);
         $sc->setQuantity(0 - $item['quantity']);
         $sc->save();
         //группируем по синтетическим счетам
         if ($types[$item['type']] > 0) {
             $types[$item['type']]['amount'] = $types[$item['type']] + $item['price'] * ($item['quantity'] / 1000);
             $types[$item['type']]['pamount'] = $types[$item['type']] + $item['partion'] * ($item['quantity'] / 1000);
             $types[$item['type']]['namount'] = $types[$item['type']] + $item['nds'];
         } else {
             $types[$item['type']]['amount'] = $item['pricends'] * ($item['quantity'] / 1000);
             $types[$item['type']]['pamount'] = $item['partion'] * ($item['quantity'] / 1000);
             $types[$item['type']]['namount'] = $item['nds'];
         }
     }
     foreach ($types as $acc => $value) {
         if ($acc == 281) {
             Entry::AddEntry("902", "281", $value['pamount'], $this->document_id, $this->document_date);
             Entry::AddEntry("36", "702", $value['amount'], $this->document_id, $this->document_date);
             if ($this->headerdata['isnds'] > 0) {
                 Entry::AddEntry("702", "643", $value['namount'], $this->document_id, $this->document_date);
             }
         }
         if ($acc == 26) {
             Entry::AddEntry("902", "26", $value['pamount'], $this->document_id, $this->document_date);
             Entry::AddEntry("36", "701", $value['amount'], $this->document_id, $this->document_date);
             if ($this->headerdata['isnds'] > 0) {
                 Entry::AddEntry("701", "643", $value['namount'], $this->document_id, $this->document_date);
             }
         }
         $sc = new SubConto($this, 36, $value['amount']);
         $sc->setCustomer($this->headerdata["customer"]);
         $sc->save();
     }
     if ($this->headerdata['cash'] == true) {
         $cash = MoneyFund::getCash();
         \ZippyERP\ERP\Entity\Entry::AddEntry("30", "36", $total, $this->document_id, $cash->id, $customer_id);
         $sc = new SubConto($this, 36, 0 - $total);
         $sc->setCustomer($this->headerdata["customer"]);
         $sc->save();
         $sc = new SubConto($this, 30, $total);
         $sc->setMoneyfund($cash->id);
         // $sc->save();
     }
     $conn->CompleteTrans();
     return true;
 }
示例#13
0
 public function Execute()
 {
     $conn = \ZCL\DB\DB::getConnect();
     $conn->StartTrans();
     $ret = 0;
     // торговая  наценка
     $amount = 0;
     foreach ($this->detaildata as $value) {
         //приниммаем на склад
         $stockto = Stock::getStock($this->headerdata['storeto'], $value['item_id'], $value['partion'], true);
         $sc = new SubConto($this, $value['type'], $value['quantity'] / 1000 * $stockto->price);
         $sc->setStock($stockto->stock_id);
         $sc->setQuantity($value['quantity']);
         $sc->save();
         $store = Store::load($this->headerdata['storefrom']);
         if ($store->store_type == Store::STORE_TYPE_RET) {
             //розница
             $stockfrom = Stock::getFirst("store_id={$this->headerdata['storefrom']} and item_id={$value['item_id']} and price={$value['price']} and partion={$value['partion']} and closed <> 1");
             if ($stockfrom == null) {
                 return false;
             }
             $sc = new SubConto($this, 282, 0 - $value['quantity'] / 1000 * $stockfrom->price);
             $sc->setStock($stockfrom->stock_id);
             $sc->setQuantity(0 - $value['quantity']);
             $sc->save();
             $ret += $value['quantity'] / 1000 * ($value['price'] - $value['partion']);
             $amount += $value['quantity'] / 1000 * $value['partion'];
         }
         if ($store->store_type == Store::STORE_TYPE_RET_SUM) {
             //розница суммовой учет
             //специальный  товар  для  cуммового  учета
             $item = \ZippyERP\ERP\Entity\Item::getSumItem();
             $stockfrom = Stock::getStock($this->headerdata['storefrom'], $item->item_id, 1, true);
             $sc = new SubConto($this, 282, 0 - $value['quantity'] * $value['price']);
             //цена  единицы  товара = 1 копейка.
             $sc->setStock($stockfrom->stock_id);
             $sc->setQuantity(0 - $value['quantity'] * $value['price']);
             //цена  единицы  товара - 1 копейка.
             $sc->save();
             $ret += $value['quantity'] / 1000 * ($value['price'] - $value['partion']);
             $amount += $value['quantity'] / 1000 * $value['partion'];
         }
     }
     if ($amount > 0) {
         // розница
         Entry::AddEntry(281, 282, $amount, $this->document_id, $this->document_date);
         Entry::AddEntry(285, 282, $ret, $this->document_id, $this->document_date);
         $sc = new SubConto($this, 285, $ret);
         $sc->setExtCode($store->store_id);
         $sc->save();
     }
     $conn->CompleteTrans();
     return true;
 }
示例#14
0
文件: store.php 项目: Niqpue/zippyerp
 /**
  * Получает список  бух. счетов к  которым  привязаны
  * ТМЦ хранищиеся  на  этом складе
  * @param mixed $store_id
  * @return массив  для   комбобокса
  */
 public static function getAccounts($store_id)
 {
     $list = array();
     $conn = \ZCL\DB\DB::getConnect();
     $sql = " select distinct sc.account_id, ap.acc_name  from erp_account_subconto sc join erp_account_plan ap on sc.account_id = ap.acc_code  where   stock_id in (select stock_id  from  erp_store_stock where   store_id = {$store_id}) order  by  ap.acc_name";
     $rs = $conn->Execute($sql);
     foreach ($rs as $row) {
         $list[$row['account_id']] = $row['acc_name'];
     }
     return $list;
 }
示例#15
0
 private function getWhere()
 {
     $conn = \ZCL\DB\DB::getConnect();
     $filter = Filter::getFilter("entrylist");
     $where = " date(document_date) >= " . $conn->DBDate($filter->from) . " and  date(document_date) <= " . $conn->DBDate($filter->to);
     if ($filter->dt > 0) {
         $where .= " and (acc_d = " . $filter->dt . " or acc_c = " . $filter->dt . ")";
     }
     if ($filter->ct > 0) {
         $where .= " and (acc_d = " . $filter->ct . " or acc_c = " . $filter->ct . ")";
     }
     return $where;
 }
示例#16
0
 private function generateReport()
 {
     $store = $this->filter->store->getValue();
     $item = $this->filter->item->getKey();
     $from = $this->filter->from->getDate();
     $to = $this->filter->to->getDate();
     $header = array('datefrom' => date('d.m.Y', $from), 'dateto' => date('d.m.Y', $to), "store" => Store::load($store)->storename, "item" => Item::load($item)->itemname, "measure" => Item::load($item)->measure_name);
     $i = 1;
     $detail = array();
     $conn = \ZCL\DB\DB::getConnect();
     $sql = "\n            SELECT\n              t.*,\n              (SELECT\n                  COALESCE(SUM(u.`quantity`), 0)\n                FROM erp_account_subconto u\n                WHERE u.`document_date` < t.dt\n                AND u.`stock_id` = t.`stock_id`) AS begin_quantity\n            FROM (\n            SELECT\n                st.stock_id,\n                price,\n                DATE(sc.document_date) AS dt,\n                SUM(\n                CASE WHEN quantity > 0 THEN quantity ELSE 0 END) AS obin,\n                SUM(\n                CASE WHEN quantity < 0 THEN 0 - quantity ELSE 0 END) AS obout,\n                GROUP_CONCAT(dc.document_number) AS docs\n              FROM\n               erp_account_subconto  sc join erp_store_stock  st on  sc.stock_id = st.stock_id\n               join erp_document  dc  on sc.document_id = dc.document_id\n\n              WHERE st.item_id = {$item}\n              AND st.store_id = {$store}\n              AND DATE(sc.document_date) >= " . $conn->DBDate($from) . "\n              AND DATE(sc.document_date) <= " . $conn->DBDate($to) . "\n              GROUP BY st.stock_id,\n                       st.price,\n                       DATE(sc.document_date)) t\n            ORDER BY dt\n        ";
     $rs = $conn->Execute($sql);
     foreach ($rs as $row) {
         $detail[] = array("no" => $i++, "date" => date("d.m.Y", strtotime($row['dt'])), "documents" => str_replace(',', '<br>', $row['docs']), "price" => H::fm($row['price']), "in" => $row['begin_quantity'] / 1000, "obin" => $row['obin'] / 1000, "obout" => $row['obout'] / 1000, "out" => ($row['begin_quantity'] + $row['obin'] - $row['obout']) / 1000);
     }
     $report = new \ZippyERP\ERP\Report('itemactivity.tpl');
     $html = $report->generate($header, $detail);
     return $html;
 }
示例#17
0
 private function generateReport()
 {
     $acc = Account::load($this->filter->acc->getValue());
     $from = $this->filter->from->getDate();
     $to = $this->filter->to->getDate();
     $header = array('from' => date('d.m.Y', $from), 'to' => date('d.m.Y', $to), 'acc' => $acc->acc_name);
     $detail = array();
     $conn = \ZCL\DB\DB::getConnect();
     $data = $acc->getSaldoAndOb($from, $to);
     //получаем остатки  и  обороты  на  период
     $sql = "select sum(case when acc_d = {$acc->acc_code} then amount else 0 end )  as ad,\n            sum(case when acc_c = {$acc->acc_code} then amount else 0 end )  as ac ,document_number,document_date\n            from erp_account_entry_view  where ( acc_d ={$acc->acc_code} or acc_c ={$acc->acc_code} ) and document_date >= " . $conn->DBDate($from) . " and document_date <= " . $conn->DBDate($to) . "  group by  document_number,document_date  order  by  document_date            ";
     $rs = $conn->Execute($sql);
     $startdt = $data['startdt'];
     $startct = $data['startct'];
     foreach ($rs as $row) {
         $amount = 0;
         $enddt = 0;
         $endct = 0;
         if ($row['ad'] > 0) {
             $amount = $row['ad'];
             $enddt = $startdt + $row['ad'];
             $endct = $startct;
         }
         if ($row['ac'] > 0) {
             $amount = 0 - $row['ac'];
             $endct = $startct + $row['ac'];
             $enddt = $startdt;
         }
         if ($enddt - $endct > 0) {
             $enddt = $enddt - $endct;
             $endct = 0;
         } else {
             $endct = $endct - $enddt;
             $enddt = 0;
         }
         $detail[] = array("date" => date("d.m.Y", strtotime($row['document_date'])), "doc" => $row['document_number'], "amount" => H::fm($amount), "startdt" => H::fm($startdt), "startct" => H::fm($startct), "enddt" => H::fm($enddt), "endct" => H::fm($endct));
         $startdt = $enddt;
         $startct = $endct;
     }
     $report = new \ZippyERP\ERP\Report('accountactivity.tpl');
     $html = $report->generate($header, $detail);
     return $html;
 }
示例#18
0
 public function savedocOnClick($sender)
 {
     $this->_doc->document_number = $this->docform->document_number->getText();
     $this->_doc->document_date = strtotime($this->docform->created->getText());
     $isEdited = $this->_doc->document_id > 0;
     $conn = \ZCL\DB\DB::getConnect();
     $conn->BeginTrans();
     try {
         $this->_doc->save();
         if ($sender->id == 'execdoc') {
             $this->_doc->updateStatus(Document::STATE_EXECUTED);
         } else {
             $this->_doc->updateStatus($isEdited ? Document::STATE_EDITED : Document::STATE_NEW);
         }
         $conn->CommitTrans();
         App::RedirectBack();
     } catch (\ZippyERP\System\Exception $ee) {
         $conn->RollbackTrans();
         $this->setError($ee->message);
     } catch (\Exception $ee) {
         $conn->RollbackTrans();
         throw new \Exception($ee->message);
     }
 }
示例#19
0
 public function savedocOnClick($sender)
 {
     if ($this->checkForm() == false) {
         return;
     }
     $this->calcTotal();
     $this->_doc->headerdata = array('customer' => $this->docform->customer->getKey(), 'customername' => $this->docform->customer->getText(), 'contract' => $this->docform->contract->getKey(), 'contractnumber' => $this->docform->contract->getText(), 'total' => $this->docform->total->getText() * 100, 'ernn' => $this->docform->ernn->isChecked(), 'author' => $this->docform->author->getText(), 'paytype' => $this->docform->paytype->getText(), 'totalnds' => $this->docform->totalnds->getText() * 100);
     $this->_doc->detaildata = array();
     foreach ($this->_tovarlist as $tovar) {
         $this->_doc->detaildata[] = $tovar->getData();
     }
     $this->_doc->amount = 100 * $this->docform->total->getText();
     $this->_doc->document_number = $this->docform->document_number->getText();
     $this->_doc->document_date = strtotime($this->docform->document_date->getText());
     $isEdited = $this->_doc->document_id > 0;
     $conn = \ZCL\DB\DB::getConnect();
     $conn->BeginTrans();
     try {
         $this->_doc->save();
         if ($sender->id == 'execdoc') {
             $this->_doc->updateStatus(Document::STATE_EXECUTED);
         } else {
             $this->_doc->updateStatus($isEdited ? Document::STATE_EDITED : Document::STATE_NEW);
         }
         if ($this->_basedocid > 0) {
             $this->_doc->AddConnectedDoc($this->_basedocid);
             $this->_basedocid = 0;
         }
         if ($this->docform->contract->getKey() > 0) {
             $this->_doc->AddConnectedDoc($this->docform->contract->getKey());
         }
         $conn->CommitTrans();
         App::RedirectBack();
     } catch (\ZippyERP\System\Exception $ee) {
         $conn->RollbackTrans();
         $this->setError($ee->message);
     } catch (\Exception $ee) {
         $conn->RollbackTrans();
         throw new \Exception($ee->message);
     }
 }
示例#20
0
 /**
  * Возвращает  файл  и  его  содержимое
  * 
  * @param mixed $file_id
  */
 public static function loadFile($file_id)
 {
     $conn = \ZCL\DB\DB::getConnect();
     $rs = $conn->Execute("select filename,filedata from erp_files join erp_filesdata on erp_files.file_id = erp_filesdata.file_id  where erp_files.file_id={$file_id}  ");
     foreach ($rs as $row) {
         return $row;
     }
     return null;
 }
示例#21
0
 private function getWhere()
 {
     $conn = \ZCL\DB\DB::getConnect();
     $filter = Filter::getFilter("taxinvoicelist");
     $where = " document_date >= " . $conn->DBDate($filter->from) . " and  document_date <= " . $conn->DBDate($filter->to);
     $where .= " and  (meta_name = 'TaxInvoice' or meta_name = 'TaxInvoiceIncome' )";
     if ($filter->notchecked == true) {
         $where .= " and intattr2  <> 1 ";
         //не  проверен  в  ЕРНН
     }
     return $where;
 }
示例#22
0
文件: cron.php 项目: Niqpue/zippyerp
<?php

require_once 'init.php';
try {
    $conn = \ZCL\DB\DB::getConnect();
    //  $conn->Execute("OPTIMIZE TABLE system_session");
    $logger->info("Cron");
} catch (Exception $e) {
    echo $e->getMessage();
    $logger->error($e);
}
示例#23
0
 public function savedocOnClick($sender)
 {
     if ($this->checkForm() == false) {
         return;
     }
     $this->calcTotal();
     $old_state = $this->_doc->headerdata['orderstate'];
     $new_state = $this->docform->orderstate->getValue();
     $this->_doc->headerdata = array('customer' => $this->docform->customer->getKey(), 'customername' => $this->docform->customer->getText(), 'orderstate' => $new_state, 'timeline' => $this->docform->timeline->getDate());
     $this->_doc->detaildata = array();
     foreach ($this->_itemlist as $item) {
         $this->_doc->detaildata[] = $item->getData();
     }
     $this->_doc->amount = 100 * $this->docform->total->getText();
     $this->_doc->document_number = $this->docform->document_number->getText();
     $this->_doc->document_date = $this->docform->document_date->getDate();
     $this->_doc->order_state = $this->docform->orderstate->getValue();
     $this->_doc->tagcode = $this->docform->customer->getKey();
     $conn = \ZCL\DB\DB::getConnect();
     $conn->BeginTrans();
     try {
         $this->_doc->save();
         if ($new_state != $old_state) {
             $this->_doc->updateStatus($new_state);
         }
         $conn->CommitTrans();
         App::RedirectBack();
     } catch (\ZippyERP\System\Exception $ee) {
         $conn->RollbackTrans();
         $this->setError($ee->message);
     } catch (\Exception $ee) {
         $conn->RollbackTrans();
         throw new \Exception($ee->message);
     }
 }
示例#24
0
 public function savedocOnClick($sender)
 {
     $this->_doc->document_date = strtotime($this->docform->document_date->getText());
     $this->_doc->document_number = $this->docform->document_number->getText();
     $this->_doc->headerdata['entry'] = base64_encode(serialize($this->_entryarr));
     $this->_doc->headerdata['emp'] = base64_encode(serialize($this->_emparr));
     $this->_doc->headerdata['item'] = base64_encode(serialize($this->_itemarr));
     $this->_doc->headerdata['c'] = base64_encode(serialize($this->_carr));
     $this->_doc->headerdata['f'] = base64_encode(serialize($this->_farr));
     $this->_doc->headerdata['description'] = $this->docform->description->getText();
     $conn = \ZCL\DB\DB::getConnect();
     $conn->BeginTrans();
     try {
         $this->_doc->save();
         if ($sender->id == 'execdoc') {
             $this->_doc->updateStatus(Document::STATE_EXECUTED);
         } else {
             $this->_doc->updateStatus($this->_edited ? Document::STATE_EDITED : Document::STATE_NEW);
         }
         $conn->CommitTrans();
         App::RedirectBack();
     } catch (\ZippyERP\System\Exception $ee) {
         $conn->RollbackTrans();
         $this->setError($ee->message);
     } catch (\Exception $ee) {
         $conn->RollbackTrans();
         throw new \Exception($ee->message);
     }
 }
示例#25
0
 protected function beforeDelete()
 {
     $conn = \ZCL\DB\DB::getConnect();
     // $conn->Execute("delete from erp_document_update_log  where document_id =" . $this->document_id);
     return true;
 }
示例#26
0
 private function getWhere()
 {
     $conn = \ZCL\DB\DB::getConnect();
     $filter = Filter::getFilter("SupplierOrderList");
     $where = " meta_name ='SupplierOrder' ";
     if ($filter->state > 0) {
         $where .= " and state =  " . $filter->state;
     }
     if ($filter->supplier > 0) {
         $where .= " and intattr1 =  " . $filter->supplier;
     }
     if ($filter->notpayed == true) {
         $where .= " and intattr2 = 0 ";
     }
     return $where;
 }
示例#27
0
 public function OnAutocomplete($sender)
 {
     $text = $sender->getValue();
     $answer = array();
     $conn = \ZCL\DB\DB::getConnect();
     $sql = "select document_id,document_number from erp_document where document_number  like '%{$text}%' and document_id <> {$this->_doc->document_id} order  by document_id desc  limit 0,20";
     $rs = $conn->Execute($sql);
     foreach ($rs as $row) {
         $answer[$row['document_id']] = $row['document_number'];
     }
     return $answer;
 }
示例#28
0
 /**
  * Получение  суммы   по  комбинации измерений
  *
  * @param mixed $date       дата на  конец дня
  * @param mixed $acc        синтетичкеский счет
  * @param mixed $stock      товар (партия)
  * @param mixed $customer   контрашент
  * @param mixed $emp        сотрудник
  * @param mixed $mf         денежный счет
  * @param mixed $code       универсальное поле
  */
 public static function getAmount($date, $acc = 0, $stock = 0, $customer = 0, $emp = 0, $mf = 0, $code = 0)
 {
     $conn = \ZCL\DB\DB::getConnect();
     $where = "   date(document_date) <= " . $conn->DBDate($date);
     if ($acc > 0) {
         $where = $where . " and account_id= " . $acc;
     }
     if ($emp > 0) {
         $where = $where . " and employee_id= " . $emp;
     }
     if ($mf > 0) {
         $where = $where . " and moneyfund_id= " . $mf;
     }
     if ($code > 0) {
         $where = $where . " and extcode= " . $code;
     }
     if ($stock > 0) {
         $where = $where . " and stock_id= " . $store;
     }
     if ($customer > 0) {
         $where = $where . " and customer_id= " . $customer;
     }
     $sql = " select coalesce(sum(amount),0) AS quantity  from erp_account_subconto  where " . $where;
     return $conn->GetOne($sql);
 }
示例#29
0
 public function savedocOnClick($sender)
 {
     if ($this->checkForm() == false) {
         return;
     }
     $this->_doc->headerdata = array('customer' => $this->docform->customer->getText());
     $this->_doc->detaildata = array();
     foreach ($this->_tovarlist as $tovar) {
         $this->_doc->detaildata[] = $tovar->getData();
     }
     $this->_doc->document_number = $this->docform->document_number->getText();
     $this->_doc->document_date = $this->docform->document_date->getDate();
     $isEdited = $this->_doc->document_id > 0;
     $conn = \ZCL\DB\DB::getConnect();
     $conn->BeginTrans();
     try {
         $this->_doc->save();
         if ($sender->id == 'execdoc') {
             $this->_doc->updateStatus(Document::STATE_EXECUTED);
         } else {
             $this->_doc->updateStatus($isEdited ? Document::STATE_EDITED : Document::STATE_NEW);
         }
         // если   создан на  основании
         if ($this->_basedocid > 0) {
             $this->_doc->AddConnectedDoc($this->_basedocid);
             $this->_basedocid = 0;
         }
         $conn->CommitTrans();
         App::RedirectBack();
     } catch (\ZippyERP\System\Exception $ee) {
         $conn->RollbackTrans();
         $this->setError($ee->message);
     } catch (\Exception $ee) {
         $conn->RollbackTrans();
         throw new \Exception($ee->message);
     }
 }
示例#30
0
文件: user.php 项目: Niqpue/zippyerp
 /**
  * Возвращает  пользователя   по  хешу
  * 
  * @param mixed $md5hash
  */
 public static function getByHash($md5hash)
 {
     $conn = \ZCL\DB\DB::getConnect();
     $arr = User::find('md5hash=' . Entity::qstr($md5hash));
     if (count($arr) == 0) {
         return null;
     }
     $arr = array_values($arr);
     return $arr[0];
 }