function addBudget($post) { global $mysql; if (!isset($post["projectId"]) && !isset($post["businessId"])) { throw new Exception("预算必须有关联的项目或者业务!"); } // 将applyBudget置为2表示当前业务可以进行预算查看了 if (isset($post["businessId"])) { editBusiness(array("id" => $post["businessId"], "applyBudget" => 2)); } $budgetId = "budget-" . date("YmdHis") . str_pad(rand(0, 9999), 4, rand(0, 9), STR_PAD_LEFT); $fields = array("projectId", "businessId", "custName", "areaSize", "totalFee", "comments", 'budgetName'); $budget = array("isDeleted" => false, "budgetId" => $budgetId); foreach ($fields as $field) { if (isset($post[$field])) { $budget[$field] = $post[$field]; } } $mysql->DBInsertAsArray("budget", $budget); //N $item = array('itemCode' => 'N', 'itemName' => '工程直接费', 'itemUnit' => '元', 'budgetId' => $budgetId); $item['budgetItemId'] = "budget-item-" . date("YmdHis") . str_pad(rand(0, 9999), 4, rand(0, 9), STR_PAD_LEFT); $mysql->DBInsertAsArray("`budget_item`", $item); //O $item = array('itemCode' => 'O', 'itemName' => '设计费3%', 'itemUnit' => '元', 'itemAmount' => 0.03, 'budgetId' => $budgetId); $item['budgetItemId'] = "budget-item-" . date("YmdHis") . str_pad(rand(0, 9999), 4, rand(0, 9), STR_PAD_LEFT); $mysql->DBInsertAsArray("`budget_item`", $item); //P $item = array('itemCode' => 'P', 'itemName' => '效果图', 'itemUnit' => '张', 'itemAmount' => 0, 'budgetId' => $budgetId); $item['budgetItemId'] = "budget-item-" . date("YmdHis") . str_pad(rand(0, 9999), 4, rand(0, 9), STR_PAD_LEFT); $mysql->DBInsertAsArray("`budget_item`", $item); //Q $item = array('itemCode' => 'Q', 'itemName' => '5%管理费', 'itemUnit' => '元', 'itemAmount' => 0.05, 'budgetId' => $budgetId); $item['budgetItemId'] = "budget-item-" . date("YmdHis") . str_pad(rand(0, 9999), 4, rand(0, 9), STR_PAD_LEFT); $mysql->DBInsertAsArray("`budget_item`", $item); //R $item = array('itemCode' => 'R', 'itemName' => '税金', 'itemUnit' => '元', 'itemAmount' => 0.03, 'budgetId' => $budgetId); $item['budgetItemId'] = "budget-item-" . date("YmdHis") . str_pad(rand(0, 9999), 4, rand(0, 9), STR_PAD_LEFT); $mysql->DBInsertAsArray("`budget_item`", $item); //S $item = array('itemCode' => 'S', 'itemName' => '工程总造价', 'itemUnit' => '元', 'budgetId' => $budgetId); $item['budgetItemId'] = "budget-item-" . date("YmdHis") . str_pad(rand(0, 9999), 4, rand(0, 9), STR_PAD_LEFT); $mysql->DBInsertAsArray("`budget_item`", $item); return array('status' => 'successful', 'errMsg' => '', "budgetId" => $budgetId); }
$res = getDesignerlist(); break; //获取业务员列表 //获取业务员列表 case "getSalesmanlist": $res = getSalesmanlist(); break; //申请将业务转为工程 //申请将业务转为工程 case "applyprojecttransference": $res = editBusiness(array('id' => $_REQUEST['businessId'], 'applyProjectTransference' => 1)); break; //申请业务预算 //申请业务预算 case "applyforbudget": $res = editBusiness(array('id' => $_REQUEST['businessId'], 'applyBudget' => 1)); break; //业务之星,上个星期谁新建的业务最多,或者最少 //业务之星,上个星期谁新建的业务最多,或者最少 case "businessStar": $desc = isset($_REQUEST['desc']) ? $_REQUEST['desc'] == "true" : false; $number = isset($_REQUEST['number']) ? intval($_REQUEST['number']) : 5; $number = $number < 1 ? 5 : $number; $startTime = date("Y-m-d H:i:s", mktime(0, 0, 0, date("m"), date("d") - date("w") + 1 - 7, date("Y"))); $endTime = date("Y-m-d H:i:s", mktime(23, 59, 59, date("m"), date("d") - date("w") + 7 - 7, date("Y"))); $res = getBusinessStar($desc, $number, $startTime, $endTime); break; //签单之星,上个星期谁签单的业务最多,或者最少 //签单之星,上个星期谁签单的业务最多,或者最少 case "signStar": $desc = isset($_REQUEST['desc']) ? $_REQUEST['desc'] == "true" : false;