コード例 #1
0
ファイル: ProjectAction.class.php プロジェクト: Aylchen/Admin
 public function delProject()
 {
     $project_id = I("post.project_id");
     $where = "`project_id`='" . $project_id . "'";
     $r = mysql_query_del($where, "project");
     mysql_query_del($where, "project_cycle");
     $this->ajaxReturn($r);
 }
コード例 #2
0
ファイル: IndexAction.class.php プロジェクト: Aylchen/Admin
 /**
  * @param max_cycle_month 收益周期中最大的月份
  */
 public function doPublish()
 {
     $project_array = $_POST;
     $type = $_POST['project_id'];
     //$type为空表示添加操作,$type不为空表示修改
     $project_id = $type != '' ? $type : random();
     $content = str_replace('src="/tczc_admin/', 'src="' . C("DIR_ROOT"), $_POST['content']);
     unset($project_array['project_id']);
     unset($project_array['content']);
     //收益类型
     $cycle_total = intval($_POST['cycle_number']);
     unset($project_array['cycle_number']);
     if ($type != '') {
         //清空所有收益类型,再进行添加操作----最简便的方式
         mysql_query_del("`project_id`='" . $project_id . "'", "project_cycle");
     }
     $cycle_month_array = array();
     for ($i = 1; $i < $cycle_total + 1; $i++) {
         $cycle_id = random();
         $cycle_array = array();
         $cycle_month_array[] = $_POST['cycle_type' . $i] == 2 ? $_POST['cycle' . $i] : $_POST['cycle' . $i] / 30;
         $cycle_array = array("cycle_id" => $cycle_id, "project_id" => $project_id, "cycle_type" => $_POST['cycle_type' . $i], "profit" => $_POST['profit' . $i], 'cycle' => $_POST['cycle' . $i]);
         mysql_query_add($cycle_array, "project_cycle");
         unset($project_array['cycle_type' . $i]);
         unset($project_array['cycle' . $i]);
         unset($project_array['profit' . $i]);
     }
     $max_cycle_month = max($cycle_month_array);
     if (!$_POST['user_id']) {
         //平台直接发起项目
         $project_array['user_id'] = md5(C("PLATFORM_ID"));
     }
     $project_array['content'] = htmlspecialchars($content);
     $project_array['status'] = 3;
     //发布
     $project_array['collect_endtime'] .= " 23:59:59";
     $endtime_stamp = strtotime("+" . $max_cycle_month . " months", strtotime($project_array['collect_endtime']));
     $project_array['endtime'] = date("Y-m-d H:i:s", $endtime_stamp);
     if ($project_array['profit_type'] == 2) {
         $project_array['endtime'] = $project_array['collect_endtime'];
     }
     if ($type != "") {
         $rst = mysql_query_save("`project_id`='" . $project_id . "'", $project_array, "project");
     } else {
         $project_array['project_id'] = $project_id;
         $project_array['ctime'] = date("Y-m-d H:i:s", time());
         $rst = mysql_query_add($project_array, "project");
     }
     $this->ajaxReturn(true);
 }