Ejemplo n.º 1
0
 public function postCreate()
 {
     $all = Sections::all();
     $section = new Sections();
     $section->title = Input::get('title');
     $section->description = Input::get('description');
     $section->type = 'section';
     $section->status = 'draft';
     $section->order = count($all) + 1;
     $section->file = Input::get('file') == 'true' ? true : false;
     if ($section->save()) {
         return Redirect::to($this->route)->with('msg_success', Lang::get('messages.sections_create', array('title' => $section->title, 'description' => $section->description, 'file' => $section->file)));
     } else {
         return Redirect::to($this->route)->with('msg_error', Lang::get('messages.sections_create_err', array('title' => $section->title, 'description' => $section->description, 'file' => $section->file)));
     }
 }
    $path = public_path() . '\\' . 'sections\\' . Input::get('shortname');
    $section = ['name_of_section' => Input::get('name_of_section'), 'sub_section' => Input::get('sub_section'), 'shortname' => Input::get('shortname'), 'section_url' => $path];
    $sections = ['name_of_section' => Input::get('name_of_section'), 'sub_section' => Input::get('sub_section'), 'shortname' => Input::get('shortname')];
    $rule = array('name_of_section' => 'required', 'shortname' => 'required');
    $validator = Validator::make($sections, $rule);
    if ($validator->fails()) {
        return Redirect::to('/section')->withErrors($validator->messages());
    } else {
        if (Input::get('sub_section') != "CWC References" && Input::get('sub_section') != "CWC Calculators") {
            //echo "Not ready";
            File::makeDirectory($path, $mode = 0777, true, true);
        } else {
            //echo "ready";
        }
        $sectionData = new Sections($section);
        $sectionData->save();
        return Redirect::to('/section')->withMessage('Section created');
    }
});
Route::post('editSectionValue', function () {
    $sections = Sections::where('id', '=', Input::get('id'))->first();
    $pages = Pages::where('page_section', '=', $sections->name_of_section)->get();
    $array = (array) $pages;
    $path = public_path() . '\\' . 'sections\\' . Input::get('shortname');
    $Uploadpath = public_path() . '\\' . 'uploads\\' . $sections->shortname;
    $section = ['name_of_section' => Input::get('name_of_section'), 'sub_section' => Input::get('sub_section'), 'shortname' => Input::get('shortname'), 'section_url' => $path];
    $sectionValues = ['name_of_section' => Input::get('name_of_section'), 'sub_section' => Input::get('sub_section'), 'shortname' => Input::get('shortname')];
    $rule = array('name_of_section' => 'required', 'shortname' => 'required');
    $validator = Validator::make($sectionValues, $rule);
    if ($validator->fails()) {
        return Redirect::to('/editSection?id=' . $sections->id)->withErrors($validator->messages());
Ejemplo n.º 3
0
    /**
     * Create project shelve and cabinet
     * @param $projectId
     * @param $year
     */
    public static function createProjectStorages($projectId, $year)
    {
        $project = Projects::model()->findByPk($projectId);

        // check existing project cabinet
        $cabinet = Storages::model()->findByAttributes(array(
            'Storage_Type' => self::CABINET,
            'Created_By' => '0',
            'Project_ID' => $projectId,
            'Year' => $year,
        ));
        if (!$cabinet) {
            // if there is not cabinet for this project create it
            $cabinet = new Storages();
            $cabinet->Storage_Name = $project->Project_Name;
            $cabinet->Project_ID = $projectId;
            $cabinet->Client_ID = Yii::app()->user->clientID;
            $cabinet->Year = $year;
            $cabinet->Created_By = 0;
            $cabinet->Row_Num = 0;
            $cabinet->Storage_Type = self::CABINET;
            $cabinet->Access_Type = self::HAS_ACCESS;
            if ($cabinet->validate()) {
                $cabinet->save();
            }
        }

        // check existing project shelf
        $shelf = Storages::model()->findByAttributes(array(
            'Storage_Type' => self::SHELF,
            'Created_By' => '0',
            'Project_ID' => $projectId,
            'Year' => $year,
        ));
        if (!$shelf) {
            // if there is not cabinet for this project create it
            $shelf = new Storages();
            $shelf->Storage_Name = $project->Project_Name;
            $shelf->Project_ID = $projectId;
            $shelf->Client_ID = Yii::app()->user->clientID;
            $shelf->Year = $year;
            $shelf->Created_By = 0;
            $shelf->Row_Num = 0;
            $shelf->Storage_Type = self::SHELF;
            $shelf->Access_Type = self::HAS_ACCESS;
            if ($shelf->validate()) {
                $shelf->save();
            }
        }

        $countW9s = W9::getCountOfAvailableW9sOfYear($year);
        if ($countW9s > 0) {
            // also crete W9 book if it does not exist and there are Company's W9s
            $w9Binder = Sections::model()->findByAttributes(array(
                'Section_Type' => self::SHELF,
                'Created_By' => '0',
                'Storage_ID' => $shelf->Storage_ID,
                'Folder_Cat_ID' => Sections::W9_BOOK,
            ));

            if (!$w9Binder) {
                $w9Binder = new Sections();
                $w9Binder->Storage_ID = $shelf->Storage_ID;
                $w9Binder->Section_Name = "W9s";
                $w9Binder->Vendor_ID = 0;
                $w9Binder->Created_By = 0;
                $w9Binder->Section_Type = self::SHELF;
                $w9Binder->Folder_Cat_ID = Sections::W9_BOOK;
                $w9Binder->Access_Type = self::HAS_ACCESS;
                if ($w9Binder->validate()) {
                    $w9Binder->save();

                    $tab = new Subsections();
                    $tab->Section_ID = $w9Binder->Section_ID;
                    $tab->Subsection_Name = 'Tab 1';
                    $tab->Subsection_Type = self::SHELF;
                    $tab->Created_By = 0;
                    $tab->Access_Type = self::HAS_ACCESS;
                    $tab->save();
                }
            }
        }
    }
 public function postAddSections()
 {
     $validator = Validator::make(Input::all(), array('section_name' => 'required|max:30|min:3'));
     if ($validator->fails()) {
         $response = array('status' => 'failed', 'msg' => 'Item is not updated', 'errors' => $validator, 'error_messages' => $validator->messages());
         return Response::json($response);
     } else {
         $section_name = Input::get('section_name');
         $section_id = Input::get('section_id');
         $class_id = Input::get('class_id');
         if ($section_id) {
             $section = Sections::find($section_id);
             $section->section_name = ucwords($section_name);
             if ($section->save()) {
                 $response = array('status' => 'success', 'msg' => 'Setting created successfully', 'errors' => null, 'data_send' => array('id' => $section->id, 'section_name' => $section->section_name));
                 return Response::json($response);
             }
         } else {
             $section = new Sections();
             $section->section_name = ucwords($section_name);
             $section->class_id = $class_id;
             if ($section->save()) {
                 $response = array('status' => 'success', 'msg' => 'Setting created successfully', 'errors' => null, 'data_send' => array('id' => $section->id, 'section_name' => $section->section_name));
                 return Response::json($response);
             }
         }
     }
     $response = array('status' => 'failed', 'msg' => 'Item is not updated');
     return Response::json($response);
 }
Ejemplo n.º 5
0
    /**
     * Create PO Log or Check Log binder for project
     * @param $projectId
     * @param $docType
     * @param $year
     * @return int
     */
    public static function createLogBinder($projectId, $docType, $year)
    {
        // get shelf
        $shelf = self::getShelfForBinderCreate($projectId, $year);

        if ($docType == Documents::PM) {
            $folderCatID = self::CHECK_LOG;
        } else if ($docType == Documents::PO) {
            $folderCatID = self::PURCHASE_ORDER_LOG;
        }

        $binder = Sections::model()->findByAttributes(array(
            'Section_Type' => Storages::SHELF,
            'Created_By' => '0',
            'Storage_ID' => $shelf->Storage_ID,
            'Folder_Cat_ID' => $folderCatID,
        ));

        if (!$binder) {
            $binder = new Sections();
            $binder->Storage_ID = $shelf->Storage_ID;
            if ($docType == Documents::PM) {
                $binder->Section_Name = 'Payments';
            } else if ($docType == Documents::PO) {
                $binder->Section_Name = 'Purchase orders';
            }
            $binder->Vendor_ID = 0;
            $binder->Created_By = 0;
            $binder->Section_Type = Storages::SHELF;
            $binder->Folder_Cat_ID = $folderCatID;
            $binder->Access_Type = Storages::HAS_ACCESS;
            if ($binder->validate()) {
                $binder->save();

                $tab = new Subsections();
                $tab->Section_ID = $binder->Section_ID;
                $tab->Subsection_Name = 'Tab 1';
                $tab->Subsection_Type = Storages::SHELF;
                $tab->Created_By = 0;
                $tab->Access_Type = Storages::HAS_ACCESS;
                $tab->save();
            }
        } else {
            $tab = Subsections::model()->findByAttributes(array(
                'Subsection_Type' => Storages::SHELF,
                'Created_By' => '0',
                'Section_ID' => $binder->Section_ID,
            ));
        }

        return $tab->Subsection_ID;
    }