Ejemplo n.º 1
0
 public function run()
 {
     if (!isAppLoaded("finance")) {
         $this->error(sprintf(lang("messages.unfoundApp"), "finance"));
         return;
     }
     if (!IS_POST) {
         $this->leaveMessage();
     }
     $theOrder = D("Orders")->find($this->mainrowId);
     $data = array("subject" => lang("Orders"), "type_id" => getTypeIdByAlias("receive", "orders"), "customer_id" => $theOrder["customer_id"], "source_model" => "Orders", "source_id" => $this->mainrowId, "amount" => $theOrder["total_amount_real"], "memo" => $_POST["message"]);
     $model = D("FinanceReceivePlan");
     $model->record($data);
 }
Ejemplo n.º 2
0
 public function run()
 {
     $thePurchase = D("Purchase")->find($this->mainrowId);
     if (!$thePurchase) {
         $this->error("not_found");
         exit;
     }
     if (!isset($_POST["donext"])) {
         $this->leaveMessage();
         exit;
     }
     $this->context["memo"] = $_POST["message"];
     $financePay = D("FinancePayPlan");
     $data = array("subject" => lang("Purchase"), "type_id" => getTypeIdByAlias("receive", "purchase"), "supplier_id" => $thePurchase["supplier_id"], "source_model" => "Purchase", "source_id" => $this->mainrowId, "amount" => $thePurchase["total_amount_real"], "memo" => $_POST["message"]);
     $financePay->record($data);
 }
Ejemplo n.º 3
0
 public function run()
 {
     if (!$_POST["donext"]) {
         $this->response(array("type" => "redirect", "location" => sprintf("/doWorkflow/Produce/makeStockin/%d/%d", $this->currentNode["id"], $this->mainrowId)));
     }
     $data = $_POST["data"];
     if (!$data["rows"]) {
         exit;
     }
     $model = D("Stockin");
     foreach ($data["rows"] as $row) {
         if ($row["id"]) {
             //标识已入库的生产详情
             $detailIds[$row["id"]] = $row["id"];
         }
     }
     $type = getTypeIdByAlias("stockin", "produce");
     $type = $type ? $type : getTypeByAlias("stockin", "other");
     $data["subject"] = "";
     $data["source_model"] = "ProducePlan";
     $data["source_id"] = $this->mainrowId;
     $data["type_id"] = $type;
     unset($data["id"]);
     list($bill, $rows) = $model->formatData($data, true);
     //        print_r($rows);
     $stockinId = $model->newBill($bill, $rows);
     //        var_dump($stockinId);
     /*
      * 更新已入库计划详情status=2
      * 检查是否所有计划内容已入库,更新生产计划status
      * **/
     if ($stockinId) {
         $detailModel = D("ProducePlanDetail");
         $detailModel->where(array("id" => array("IN", implode(",", $detailIds))))->save(array("status" => 2));
         $num = $detailModel->where(array("plan_id" => $this->mainrowId, "status" => array("LT", 2)))->count("id");
         if ($num <= 0) {
             D("ProducePlan")->where("id=" . $this->mainrowId)->save(array("status" => 4));
         } else {
             exit;
         }
         //            echo $detailModel->getLastSql();exit;
     } else {
         exit;
     }
     //        var_dump($stockinId);
     //        exit;
 }
Ejemplo n.º 4
0
 public function run()
 {
     $this->updateStatus("Returns", $this->mainrowId, 2);
     //财务
     if (isModuleEnabled("Finance")) {
         $returns = D("Returns");
         $theReturns = $returns->find($this->mainrowId);
         $financeModel = D("FinancePayPlan");
         $data = array("source_model" => "Returns", "source_id" => $this->mainrowId, "subject" => $theReturns["subject"], "supplier_id" => $theReturns["customer_id"], "amount" => $theReturns["total_price_real"], "create_dateline" => CTS, "status" => 0, "type_id" => getTypeIdByAlias("pay", "returns"), "user_id" => getCurrentUid());
         $lastId = $financeModel->add($data);
         //            echo $lastId;exit;
         //            echo $financeModel->getLastSql();exit;
         import("@.Workflow.Workflow");
         $workflow = new Workflow("financePay");
         $node = $workflow->doNext($lastId, "", true);
         //            var_dump($node);
     }
 }
Ejemplo n.º 5
0
 public function ACT_analytics()
 {
     $quick = $_GET["_filter_timeStep"];
     switch ($quick) {
         case "year":
             $starttime = strtotime(date("Y", CTS) - 5 . "-00-00");
             $endtime = strtotime(date("Y", CTS) + 1 . "-01-02");
             $step = 24 * 3600 * 365;
             $format = "Y";
             break;
         case "month":
             $starttime = strtotime(date("Y-01-01", CTS));
             $endtime = strtotime(date("Y-12-31", CTS));
             $step = 24 * 3600 * 31;
             $format = "Y-m";
             break;
         default:
             $starttime = strtotime(date("Y-m", CTS));
             $endtime = strtotime(date("Y-m-d"));
             $step = 24 * 3600;
             $format = "m-d";
             break;
     }
     if ($_GET["_filter_start_dateline"]) {
         $starttime = strtotime($_GET["_filter_start_dateline"]);
     }
     if ($_GET["_filter_end_dateline"]) {
         $endtime = strtotime($_GET["_filter_end_dateline"]);
     }
     switch ($_GET["type"]) {
         case "top_20_customer":
         case "by_saler":
         case "by_department":
             $model = "OrdersView";
             break;
         default:
             $model = "Orders";
     }
     $map = array("status" => array("EGT", 1), "sale_type" => getTypeIdByAlias("sale", "sale"), "dateline" => array("BETWEEN", array($starttime, $endtime)));
     $orderModel = D($model);
     $orderModel->includeWorkflowProcess = false;
     $orderSourceData = $orderModel->where($map)->select();
     //        print_r($orderSourceData);exit;
     //        $this->response($orderSourceData);
     switch ($_GET["type"]) {
         case "top_20_customer":
             $data = $this->ForCustomerRange($orderSourceData);
             break;
         case "by_saler":
             $data = $this->ForSalerRange($orderSourceData, $starttime, $endtime, $step, $format);
             break;
         case "by_department":
             $data = $this->ForDepartmentRange($orderSourceData, $starttime, $endtime, $step, $format);
             break;
         default:
             $data = $this->ForSaleTotal($orderSourceData, $starttime, $endtime, $step, $format);
     }
     $this->response($data);
 }