public function outlineCommit()
 {
     //outline_id
     $outline_id = isset($_POST['outline_id']) ? trim($_POST['outline_id']) : null;
     $dataEntity = array();
     $arr = array();
     $jsondata = array();
     $jsondata['code'] = 1;
     $i = 0;
     $cp = new CommonPRM();
     $btbTrainingplanOutlinePRM = new BtbTrainingplanOutlinePRM();
     $btbTrainingplanOutlineDetailSportitemPRM = new BtbTrainingplanOutlineDetailSportitemPRM();
     //部分课时还未添加动作,请补充完整再提交审核
     $btbTrainingplanOutlineDetailPRM = new BtbTrainingplanOutlineDetailPRM();
     $btbTrainingplanOutlineDetailPRM->outline_id = $outline_id;
     $btbTrainingplanOutlineDetailSportitemPRM->outline_id = $outline_id;
     $trainingplanOutlineDetailList = BtbTrainingplanOutlineDetailBLL::getTrainingplanOutlineDetailList($cp, $btbTrainingplanOutlineDetailPRM);
     foreach ($trainingplanOutlineDetailList as $todList) {
         if ($todList['bodypart'] == '') {
             $jsondata['code'] = -4;
             $jsondata['msg'] = "请选择当天的单天重点";
             $arr[0] = $jsondata;
             $this->ajaxReturn($arr);
             return;
         }
         $btbTrainingplanOutlineDetailSportitemPRM->outline_detail_id = $todList['id'];
         $trainingplanOutlineDetailSportitemList = BtbTrainingplanOutlineDetailSportitemBLL::getTrainingplanOutlineDetailSportitemList($cp, $btbTrainingplanOutlineDetailSportitemPRM);
         if (count($trainingplanOutlineDetailSportitemList) == 0) {
             $jsondata['code'] = -3;
             $jsondata['msg'] = "部分课时还未添加动作,请补充完整再提交审核";
             $arr[0] = $jsondata;
             $this->ajaxReturn($arr);
             return;
         }
     }
     //outline_detail_id
     //$outline_detail_id = isset($_POST['outline_detail_id']) ? trim($_POST['outline_detail_id']):null;
     //$outline_id = 46;
     if ($jsondata['code'] != -3) {
         //查看动作是否审核过
         //$btbTrainingplanOutlineDetailSportitemPRM->outline_detail_id = $outline_detail_id;
         //初始化outline_detail_id
         $btbTrainingplanOutlineDetailSportitemPRM->outline_detail_id = '';
         $trainingplanOutlineDetailSportitemList = BtbTrainingplanOutlineDetailSportitemBLL::getTrainingplanOutlineDetailSportitemList($cp, $btbTrainingplanOutlineDetailSportitemPRM);
         //if(count($trainingplanOutlineDetailSportitemList)== 0)
         //    	{
         //
         //    	}
         foreach ($trainingplanOutlineDetailSportitemList as $todsList) {
             //查看动作表里是否有动作
             $btbTrainingplanOutlineDetailSportitemPRM->name = $todsList['name'];
             $btbTrainingplanOutlineDetailSportitemPRM->source_outline_id = $outline_id;
             $btbTrainingplanOutlineDetailSportitemPRM->source_outline_detail_id = $todsList['outline_detail_id'];
             $data = BtbTrainingplanOutlineDetailSportitemBLL::getTrainingplanOutlineDetailSportitemWithSportitemBaseList($cp, $btbTrainingplanOutlineDetailSportitemPRM);
             //没有动作
             if (count($data) == 0) {
                 //$dataEntity[]['name'] =$todsList['name'];
                 $dataEntity['name'] = $todsList['name'];
                 $dataEntity['source_outline_id'] = $todsList['outline_id'];
                 $dataEntity['source_outline_detail_id'] = $todsList['outline_detail_id'];
                 //查训练方案名称
                 $btbTrainingplanOutlinePRM->id = $todsList['outline_id'];
                 $trainingplanOutlineList = BtbTrainingplanOutlineBLL::getTrainingplanOutlineList($cp, $btbTrainingplanOutlinePRM);
                 if (count($trainingplanOutlineList) > 0) {
                     $outline_name = $trainingplanOutlineList[0]['name'];
                     //创建人id
                     $dataEntity['obj_createuser'] = $trainingplanOutlineList[0]['coach_id'];
                 }
                 //查第几天
                 $btbTrainingplanOutlineDetailPRM->id = $todsList['outline_detail_id'];
                 $trainingplanOutlineDetailList = BtbTrainingplanOutlineDetailBLL::getTrainingplanOutlineDetailList($cp, $btbTrainingplanOutlineDetailPRM);
                 if (count($trainingplanOutlineDetailList) > 0) {
                     $day = $trainingplanOutlineDetailList[0]['day'];
                 }
                 //徒手训练第1节
                 $dataEntity['source'] = $outline_name . '第' . $day . '节';
                 //未提交
                 $dataEntity['auditstatus'] = 0;
                 $rows = BtbSportitemBaseBLL::btbSportitemBaseInsert($dataEntity);
                 if ($rows > 0) {
                     //$flag = 1;
                     //计算有多少个动作解析
                     $jsondata['code'] = 1;
                     $i = $i + 1;
                     //更新大纲详情动作表sportitem_base_id
                     $dataTrainingplanOutlineDetailSportitem = array();
                     $dataTrainingplanOutlineDetailSportitem['id'] = $todsList['id'];
                     $dataTrainingplanOutlineDetailSportitem['sportitem_base_id'] = $rows;
                     $rowsTrainingplanOutlineDetailSportitem = BtbTrainingplanOutlineDetailSportitemBLL::btbTrainingplanOutlineDetailSportitemUpdate($dataTrainingplanOutlineDetailSportitem);
                     if ($rowsTrainingplanOutlineDetailSportitem > 0) {
                         $jsondata['code'] = 1;
                     } else {
                         $jsondata['code'] = -5;
                         $jsondata['msg'] = "大纲详情动作表更新失败";
                     }
                 } else {
                     //$flag = 0;
                     $jsondata['msg'] = "动作组插入失败";
                     $jsondata['code'] = -1;
                 }
             }
         }
         //$jsondata['code'] = 1;
         if ($jsondata['code'] == 1) {
             //改变提交状态
             $outlinedata = array();
             $outlinedata['id'] = $outline_id;
             //0未提交 1审核中 2 已审核  -1 审核未通过
             $outlinedata['auditstatus'] = 1;
             $outlinerows = BtbTrainingplanOutlineBLL::btbTrainingplanOutlineUpdate($outlinedata);
             if ($outlinerows > 0) {
                 //$flag = 1;大纲状态更新成功
                 $jsondata['code'] = 1;
             } else {
                 //$flag = 0;
                 $jsondata['msg'] = "大纲状态更新失败";
                 $jsondata['code'] = -2;
             }
         }
     }
     //$arr[0] = $flag;
     $arr[0] = $jsondata;
     $arr[1] = $i;
     $this->ajaxReturn($arr);
 }
 public function sportitemgUpdateIndex()
 {
     $cp = new CommonPRM();
     //根据id查动作组详情
     $trainingplan_outline_detail_sportitem_id = isset($_POST['trainingplan_outline_detail_sportitem_id']) ? trim($_POST['trainingplan_outline_detail_sportitem_id']) : null;
     //$trainingplan_outline_detail_sportitem_id =11;
     $btbTrainingplanSportitemgroupDetailPRM = new BtbTrainingplanSportitemgroupDetailPRM();
     $btbTrainingplanSportitemgroupDetailPRM->id = $trainingplan_outline_detail_sportitem_id;
     $trainingplanSportitemgroupDetailByIdList = BtbTrainingplanSportitemgroupDetailBLL::getTrainingplanSportitemgroupDetailByIdList($cp, $btbTrainingplanSportitemgroupDetailPRM);
     $trainingplanSportitemgroupDetailByIdList = $trainingplanSportitemgroupDetailByIdList[0];
     //根据动作组表展示大纲动作列表
     //查询动作(根据已审核的单天大纲内容,提供可选择动作)
     $outline_id = isset($_POST['outline_id']) ? trim($_POST['outline_id']) : null;
     //$outline_id = 48;
     //outline_detail_id
     $outline_detail_id = isset($_POST['outline_detail_id']) ? trim($_POST['outline_detail_id']) : null;
     //$outline_detail_id = 80;
     //sportitemgrouptype
     $sportitemgrouptype = isset($_POST['sportitemgrouptype']) ? trim($_POST['sportitemgrouptype']) : null;
     //$sportitemgrouptype = 2;
     $btbTrainingplanOutlineDetailSportitemPRM = new BtbTrainingplanOutlineDetailSportitemPRM();
     $btbTrainingplanOutlineDetailSportitemPRM->outline_id = $outline_id;
     $btbTrainingplanOutlineDetailSportitemPRM->outline_detail_id = $outline_detail_id;
     $btbTrainingplanOutlineDetailSportitemPRM->sportitemgrouptype = $sportitemgrouptype;
     $sportitemBaseList = BtbTrainingplanOutlineDetailSportitemBLL::getTrainingplanOutlineDetailSportitemWithSportitemBaseList($cp, $btbTrainingplanOutlineDetailSportitemPRM);
     //		$data = array();
     //		foreach ($sportitemBaseList as $sbList)
     //		{
     //
     //			//array_push($sbList,$trainingplanSportitemgroupDetailByIdList['count'],$trainingplanSportitemgroupDetailByIdList['groupcount'],$trainingplanSportitemgroupDetailByIdList['grouptype']);
     //			$sbList['count'] = $trainingplanSportitemgroupDetailByIdList['count'];
     //			$sbList['groupcount'] = $trainingplanSportitemgroupDetailByIdList['groupcount'];
     //			$sbList['grouptype'] = $trainingplanSportitemgroupDetailByIdList['grouptype'];
     //			$sbList['sid'] = $trainingplanSportitemgroupDetailByIdList['sbid'];
     //			$data[] = $sbList;
     //			//dump($sbList);
     //		}
     $count = count($sportitemBaseList);
     $sportitemBaseList[$count]['count'] = $trainingplanSportitemgroupDetailByIdList['count'];
     $sportitemBaseList[$count]['groupcount'] = $trainingplanSportitemgroupDetailByIdList['groupcount'];
     $sportitemBaseList[$count]['grouptype'] = $trainingplanSportitemgroupDetailByIdList['grouptype'];
     $sportitemBaseList[$count]['sbid'] = $trainingplanSportitemgroupDetailByIdList['sbid'];
     //dump($sportitemBaseList);
     //dump(count($sportitemBaseList));
     //dump($data);
     if (count($sportitemBaseList) > 0) {
         $this->ajaxReturn($sportitemBaseList);
     }
 }