public function beginRegistration($params = array())
 {
     $defaults = array('registration_email' => $registration_email = null, 'name' => $name = null);
     $rules = array('registration_email' => array('required', 'email'), 'name' => array('required'));
     $params = $this->validateParams($defaults, $params, $rules);
     extract($params);
     $organization = new Organization();
     $organization->registration_email = $registration_email;
     $organization->name = $name;
     $organization->save();
     $this->entity = $organization;
     $this->api->event->fire(new OrganizationRegistrationBegan($organization));
     return $this->entity();
 }
 protected function create($values)
 {
     $data = [];
     foreach ($this->structure as $i => $key) {
         $data[$key] = $values[$i];
     }
     Organization::create($data);
 }
 public static function bootMultiTenantTrait()
 {
     static::addGlobalScope(new MultiTenantScope());
     static::saving(function ($model) {
         $organization = Organization::current();
         $model->organization_id = $organization->id;
     });
 }
 public function __construct(ApiContract $api, Request $request)
 {
     $this->api = $api;
     $this->request = $request;
     if ($organization_id = $request->get('organization_id', false)) {
         $organization = Organization::findOrFailCached($organization_id);
         Organization::setCurrent($organization);
     }
     $this->setupMiddleware();
 }
 /**
  * Remove the scope from the given Eloquent query builder.
  *
  * @param  \Illuminate\Database\Eloquent\Builder $builder
  * @param  \Illuminate\Database\Eloquent\Model $model
  *
  * @return void
  */
 public function remove(Builder $builder, Model $model)
 {
     $organization = Organization::current();
     $query = $builder->getQuery();
     foreach ((array) $query->wheres as $key => $where) {
         if ($where['type'] == $organization->id && $where['column'] == 'organization_id') {
             unset($query->wheres[$key]);
             $query->wheres = array_values($query->wheres);
         }
     }
 }
示例#6
0
 public function attemptToJoin(Organization $organization)
 {
     /**
      * If the user is the admin of this organization.
      */
     if ($this->hasRole($organization->roleAdminName())) {
         $this->organizations()->attach($this->id);
         return true;
     }
     /**
      * If the user's email is in one of the organization's allowed email domains.
      */
     $user_email_domain = array_pop(explode('@', $this->email));
     if ($organization->emailDomains()->where('domain', $user_email_domain)->exists()) {
         $this->organizations()->attach($this->id);
         return true;
     }
     // TODO: check if user is one of the invited
     return false;
 }
示例#7
0
 /**
  * @param string $message
  * @return User
  * @throws \App\Exceptions\ForbiddenException
  * @throws \App\Exceptions\MultiTenantException
  */
 public function adminsOnly($message = 'Only admins may do this.')
 {
     $user = $this->mustBeLoggedIn();
     if ($user->hasRole(Role::ROLE_SUPER_ADMIN)) {
         return $user;
     }
     $organization = Organization::current();
     if ($user->hasRole($organization->roleAdminName())) {
         return $user;
     }
     throw new ForbiddenException($message);
 }
 /**
  * Execute the job.
  *
  * @return void
  */
 public function handle()
 {
     // ------------------------------------------------------------
     // Save Organization
     // ------------------------------------------------------------
     $organization = new Organization($this->organization_data);
     if (!$organization->save()) {
         return JSend::fail($organization->getErrors()->toArray());
     }
     // ------------------------------------------------------------
     // Assign Owner
     // ------------------------------------------------------------
     $this->dispatch(new AddUserToOrganization($organization, $user, true));
     // ------------------------------------------------------------
     // Email Owner
     // ------------------------------------------------------------
     $this->dispatch(new NotifyOwnerAfterOrganizationCreated($organization, $user));
     // ------------------------------------------------------------
     // Email Admin
     // ------------------------------------------------------------
     $this->dispatch(new NotifyOwnerAfterOrganizationCreated($organization, $user));
 }
示例#9
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Organization::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['org_id' => $this->org_id, 'created_at' => $this->created_at, 'created_by' => $this->created_by, 'updated_at' => $this->updated_at, 'updated_by' => $this->updated_by]);
     $query->andFilterWhere(['like', 'org_name', $this->org_name])->andFilterWhere(['like', 'org_alias', $this->org_alias])->andFilterWhere(['like', 'org_address_line1', $this->org_address_line1])->andFilterWhere(['like', 'org_address_line2', $this->org_address_line2])->andFilterWhere(['like', 'org_phone', $this->org_phone])->andFilterWhere(['like', 'org_email', $this->org_email])->andFilterWhere(['like', 'org_website', $this->org_website])->andFilterWhere(['like', 'org_logo', $this->org_logo])->andFilterWhere(['like', 'org_logo_type', $this->org_logo_type]);
     return $dataProvider;
 }
 /**
  * Creates a new CountryOrgRel model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate($oid)
 {
     $org = Organization::findOne(['id' => $oid]);
     $countries = Country::find()->all();
     $rels = CountryOrgRel::find()->where(['org_id' => $oid])->all();
     $model = new CountryOrgRel();
     if (Yii::$app->request->post()) {
         $model->load(Yii::$app->request->post());
         $count = CountryOrgRel::find()->where(['org_id' => $model->org_id, 'country_id' => $model->country_id])->count();
         if ($count == 0) {
             $model->save();
         }
         return $this->redirect(['create', 'oid' => $model->org_id]);
     } else {
         return $this->render('create', ['model' => $model, 'org' => $org, 'countries' => $countries, 'rels' => $rels]);
     }
 }
示例#11
0
 public function exportData($title = '', $filename = 'Edusec Pdf', $html = NULL)
 {
     $mpdf = new mPDF('utf-8', 'A4', 0, '', 15, 15, 25, 16, 4, 9, 'P');
     $org = Organization::find()->asArray()->one();
     $src = Yii::$app->urlManager->createAbsoluteUrl('site/loadimage');
     $org_image = Html::img($src, ['alt' => 'No Image', 'width' => 90, 'height' => 70]);
     $org_name = $org['org_name'];
     $org_add = $org['org_address_line1'] . "<br/>" . $org['org_address_line2'];
     $mpdf->SetHTMLHeader('<table style="border-bottom:1.6px solid #999998;border-top:hidden;border-left:hidden;border-right:hidden;width:100%;"><tr style="border:hidden"><td vertical-align="center" style="width:35px;border:hidden" align="left">' . $org_image . '</td><td style="border:hidden;text-align:left;color:#555555;"><b style="font-size:22px;">' . $org_name . '</b><br/><span style="font-size:10.2px">' . $org_add . '</td></tr></table>');
     $stylesheet = file_get_contents('css/pdf.css');
     // external css
     $mpdf->WriteHTML($stylesheet, 0);
     $mpdf->WriteHTML('<watermarkimage src=' . $src . ' alpha="0.33" size="50,30"/>');
     $mpdf->showWatermarkImage = true;
     $arr = ['odd' => ['L' => ['content' => $title, 'font-size' => 10, 'font-style' => 'B', 'font-family' => 'serif', 'color' => '#27292b'], 'C' => ['content' => 'Page - {PAGENO}/{nbpg}', 'font-size' => 10, 'font-style' => 'B', 'font-family' => 'serif', 'color' => '#27292b'], 'R' => ['content' => 'Printed @ {DATE j-m-Y}', 'font-size' => 10, 'font-style' => 'B', 'font-family' => 'serif', 'color' => '#27292b'], 'line' => 1], 'even' => []];
     $mpdf->SetFooter($arr);
     $mpdf->WriteHTML('<sethtmlpageheader name="main" page="ALL" value="on" show-this-page="1">');
     $mpdf->WriteHTML($html);
     $mpdf->Output($filename . '.pdf', "I");
 }
示例#12
0
文件: _form.php 项目: EduSec/EduSec
	<h4 class="box-title"><i class="fa fa-info-circle"></i> <?php 
echo Yii::t('emp', 'Personal Details');
?>
</h4>
    </div>
    <div class="box-body">
	
<div class="col-xs-12 col-lg-12 col-sm-12">
	<div class = "col-sm-4 col-xs-9">
	     <?php 
echo $form->field($info, 'emp_unique_id', ['inputOptions' => ['class' => 'form-control', 'placeholder' => 'Unique Id']])->textInput(['value' => $empno]);
?>
	</div>
	<div class="col-xs-3 col-sm-8 edusecArLangPopover" style="padding-top: 25px;">
	<?php 
$emp_login_prefix = \app\models\Organization::find()->one()->org_emp_prefix;
?>
		<button type="button" class="btn btn-danger" data-html=true data-toggle="popover" title="<?php 
echo Yii::t('emp', 'Employee Login Note');
?>
" data-trigger="focus" data-content="<?php 
echo Yii::t('stu', 'Unique Id is used as login username with');
?>
 <b><?php 
echo $emp_login_prefix;
?>
 </b><?php 
echo Yii::t('stu', 'prefix.');
?>
 </br> <?php 
echo Yii::t('stu', 'Example: If Unique id : 123 so, Username :');
示例#13
0
 /**
  * Creates a new EmpMaster model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new EmpMaster();
     $info = new EmpInfo();
     $user = new User();
     $address = new EmpAddress();
     $auth_assign = new AuthAssignment();
     $empUniqueId = EmpInfo::find()->max('emp_unique_id');
     $empno = null;
     if (empty($empUniqueId)) {
         $empno = $info->emp_unique_id = 1;
     } else {
         $chkId = EmpInfo::find()->where(['emp_unique_id' => $empUniqueId])->exists();
         if ($chkId) {
             $empno = $empUniqueId + 1;
         } else {
             $empno = $empUniqueId;
         }
     }
     if ($model->load(Yii::$app->request->post()) && $info->load(Yii::$app->request->post())) {
         if (Yii::$app->request->isAjax) {
             \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
             return ActiveForm::validate($info);
         }
         if (Yii::$app->request->isAjax) {
             \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
             return ActiveForm::validate($model);
         }
         $model->attributes = $_POST['EmpMaster'];
         $info->attributes = $_POST['EmpInfo'];
         $info->emp_dob = Yii::$app->dateformatter->getDateFormat($_POST['EmpInfo']['emp_dob']);
         $info->emp_joining_date = Yii::$app->dateformatter->getDateFormat($_POST['EmpInfo']['emp_joining_date']);
         $info->emp_unique_id = $empno;
         if (empty($_POST['EmpInfo']['emp_email_id'])) {
             $info->emp_email_id = NULL;
         } else {
             $info->emp_email_id = strtolower($info->emp_email_id);
         }
         $user->user_login_id = \app\models\Organization::find()->one()->org_emp_prefix . $info->emp_unique_id;
         $user->user_password = md5($user->user_login_id . $user->user_login_id);
         $user->user_type = "E";
         $user->created_by = Yii::$app->getid->getId();
         $user->created_at = new \yii\db\Expression('NOW()');
         if ($info->save(false)) {
             $user->save(false);
             $address->save(false);
         }
         $model->emp_master_emp_address_id = $address->emp_address_id;
         $model->emp_master_emp_info_id = $info->emp_info_id;
         $model->emp_master_user_id = $user->user_id;
         $model->created_by = Yii::$app->getid->getId();
         $model->created_at = new \yii\db\Expression('NOW()');
         $model->save(false);
         $emp_info = EmpInfo::findOne($model->emp_master_emp_info_id);
         $emp_info->emp_info_emp_master_id = $model->emp_master_id;
         $emp_info->save(false);
         $auth_assign->item_name = 'Employee';
         $auth_assign->user_id = $user->user_id;
         $auth_assign->created_at = date_format(date_create(), 'U');
         $auth_assign->save(false);
         if ($model->save(false)) {
             return $this->redirect(['view', 'id' => $model->emp_master_id]);
         } else {
             return $this->render('create', ['model' => $model, 'info' => $info, 'user' => $user, 'empno' => $empno]);
         }
     } else {
         return $this->render('create', ['model' => $model, 'info' => $info, 'user' => $user, 'empno' => $empno]);
     }
 }
示例#14
0
     <p class="note">Fields with <span class="required"> <b style=color:red;>*</b></span> are required.</p>
    <?php 
$form = ActiveForm::begin(['id' => 'stu-master-form', 'enableAjaxValidation' => true, 'fieldConfig' => ['template' => "{label}{input}{error}"]]);
?>
    
  
    <div class="box box-solid box-info col-xs-12 col-lg-12 no-padding">
      <div class="box-header with-border">
         <h4 class="box-title"><i class="fa fa-info-circle"></i> Personal Details</h4>
      </div>
    <div class="box-body">

   <div class="col-xs-12 col-sm-12 col-lg-12 no-padding">
    <div class="col-xs-9 col-sm-4">
	<?php 
$stu_login_prefix = \app\models\Organization::find()->one()->org_stu_prefix;
?>
	<?php 
echo $form->field($info, 'stu_unique_id', ['template' => '{label}{input}{error}'])->textInput(['value' => $uniq_id]);
?>
    </div>
    <div class="col-xs-3 col-sm-8" style="padding-top: 25px;">
	<button type="button" class="btn btn-danger" data-html=true data-toggle="popover" title="Student Login Note" data-trigger="focus" data-content="Unique Id is used as login username with <b><?php 
echo $stu_login_prefix;
?>
 </b>prefix. </br> Example: If Unique id : 123 so, Username : <?php 
echo $stu_login_prefix;
?>
123"><i class="fa fa-info-circle"></i></button>
    </div>
   </div>
 public function postCalcSumsFirstEnter($id)
 {
     $sum_org_movables_carrying_amount = 0;
     $sum_org_value_movables_carrying_amount = 0;
     $sum_org_buildings_carrying_amount = 0;
     $sum_org_parcels_carrying_amount = 0;
     $sum_org_movables_residual_value = 0;
     $sum_org_value_movables_residual_value = 0;
     $sum_org_buildings_residual_value = 0;
     $sum_org_cars_carrying_amount = 0;
     $sum_org_cars_residual_value = 0;
     $user = \App\Models\Organization::find($id)->user;
     $documents = \App\Models\User::find($user->id)->documents;
     $documents = $documents->where('document_type', 'residues_entering');
     foreach ($documents as $document) {
         $type = $document->os_type;
         if ($type == 'movables') {
             $sum_org_movables_carrying_amount = $sum_org_movables_carrying_amount + $document->doc_carrying_amount;
             $sum_org_movables_residual_value = $sum_org_movables_residual_value + $document->doc_residual_value;
         }
         if ($type == 'value_movables') {
             $sum_org_value_movables_carrying_amount = $sum_org_value_movables_carrying_amount + $document->doc_carrying_amount;
             $sum_org_value_movables_residual_value = $sum_org_value_movables_residual_value + $document->doc_residual_value;
         }
         if ($type == 'car') {
             $sum_org_cars_carrying_amount = $sum_org_cars_carrying_amount + $document->doc_carrying_amount;
             $sum_org_cars_residual_value = $sum_org_cars_residual_value + $document->doc_residual_value;
         }
         if ($type == 'buildings') {
             $sum_org_buildings_carrying_amount = $sum_org_buildings_carrying_amount + $document->doc_carrying_amount;
             $sum_org_buildings_residual_value = $sum_org_buildings_residual_value + $document->doc_residual_value;
         }
         if ($type == 'parcels') {
             $sum_org_parcels_carrying_amount = $sum_org_parcels_carrying_amount + $document->doc_carrying_amount;
         }
     }
     $organization_id = $user->organization_id;
     $organization = \App\Models\Organization::find($organization_id);
     $organization->org_movables_carrying_amount = $sum_org_movables_carrying_amount;
     $organization->org_value_movables_carrying_amount = $sum_org_value_movables_carrying_amount + $sum_org_cars_carrying_amount;
     $organization->org_cars_carrying_amount = $sum_org_cars_carrying_amount;
     $organization->org_buildings_carrying_amount = $sum_org_buildings_carrying_amount;
     $organization->org_parcels_carrying_amount = $sum_org_parcels_carrying_amount;
     $organization->org_movables_residual_value = $sum_org_movables_residual_value;
     $organization->org_value_movables_residual_value = $sum_org_value_movables_residual_value + $sum_org_cars_residual_value;
     $organization->org_buildings_residual_value = $sum_org_buildings_residual_value;
     $organization->org_cars_residual_value = $sum_org_cars_residual_value;
     $organization->org_carrying_amount = $organization->org_movables_carrying_amount + $organization->org_value_movables_carrying_amount + $organization->org_buildings_carrying_amount + $organization->org_parcels_carrying_amount;
     $organization->org_residual_value = $organization->org_movables_residual_value + $organization->org_value_movables_residual_value + $organization->org_buildings_residual_value;
     $organization->save();
     return redirect()->back();
 }
示例#16
0
 public function importStuData($model)
 {
     $dispResults = [];
     $totalSuccess = 0;
     $objPHPExcel = PHPExcel_IOFactory::load($model->importFilePath . $model->importFile);
     $sheetData = $objPHPExcel->getActiveSheet()->toArray(null, true, true, true);
     //print_r($sheetData); exit;
     unset($sheetData[1]);
     //start import student row by row
     foreach ($sheetData as $k => $line) {
         //print_r($line); exit;
         if (!array_filter($line)) {
             continue;
         }
         $line = array_map('trim', $line);
         $line = array_map(function ($value) {
             return empty($value) ? NULL : $value;
         }, $line);
         $stuMaster = new StuMaster();
         $stuInfo = new StuInfo();
         $stuInfo->scenario = 'import-stu';
         $stuAddress = new StuAddress();
         $user = new User();
         $auth_assign = new AuthAssignment();
         //set student info attributes
         $stuInfo->stu_unique_id = $stuInfo->getUniqueId();
         // Student Unique Id
         $stuInfo->stu_title = $this->valueReplace($line['A'], $stuInfo->getTitleOptions());
         //Title Name
         $stuInfo->stu_first_name = $line['B'];
         //First Name
         $stuInfo->stu_last_name = $line['C'];
         //Last Name
         $stuInfo->stu_dob = Yii::$app->dateformatter->getDateFormat($line['D']);
         //Date of Birth
         $stuInfo->stu_admission_date = Yii::$app->dateformatter->getDateFormat($line['H']);
         //Student Admission Date
         $stuInfo->stu_gender = $this->valueReplace($line['I'], $stuInfo->getGenderOptions());
         // Gender
         $stuInfo->stu_email_id = $line['J'];
         // Email ID
         $stuInfo->stu_mobile_no = $line['K'];
         // Mobile No
         //set student master attribute
         $stuMaster->stu_master_course_id = $this->valueReplace($line['E'], Courses::getStuCourse());
         // Course
         $stuMaster->stu_master_batch_id = $this->valueReplace($line['F'], Batches::getStuBatches());
         // Batch
         $stuMaster->stu_master_section_id = $this->valueReplace($line['G'], Section::getStuSection());
         // Section
         $stuMaster->stu_master_category_id = $this->valueReplace($line['L'], StuCategory::getStuCategoryId());
         //Admission Category
         $stuMaster->stu_master_nationality_id = $this->valueReplace($line['M'], Nationality::getNationality());
         //Nationality
         //set student address attribute
         $stuAddress->stu_cadd = $line['N'];
         //Current Address
         $stuAddress->stu_cadd_city = $this->valueReplace($line['O'], City::getAllCity());
         //City
         $stuAddress->stu_cadd_state = $this->valueReplace($line['P'], State::getAllState());
         //State
         $stuAddress->stu_cadd_country = $this->valueReplace($line['Q'], Country::getAllCountry());
         //Country
         $stuAddress->stu_cadd_pincode = $line['R'];
         //Pincode
         $stuAddress->stu_cadd_house_no = $line['S'];
         //House No
         $stuAddress->stu_cadd_phone_no = $line['T'];
         //Phone No
         //set user login info attributes
         $uniq_id = $stuInfo->getUniqueId();
         $login_id = \app\models\Organization::find()->one()->org_stu_prefix . $uniq_id;
         $user->user_login_id = $login_id;
         //user login id
         $user->user_password = md5($user->user_login_id . $user->user_login_id);
         //user password
         $user->user_type = "S";
         //user type
         $user->created_by = Yii::$app->getid->getId();
         //created by
         $user->created_at = new \yii\db\Expression('NOW()');
         //created at
         if ($user->validate() && $stuInfo->validate() && $stuAddress->validate()) {
             $transaction = Yii::$app->db->beginTransaction();
             try {
                 if ($stuInfo->save() && $user->save() && $stuAddress->save()) {
                     $stuMaster->stu_master_stu_info_id = $stuInfo->stu_info_id;
                     $stuMaster->stu_master_user_id = $user->user_id;
                     $stuMaster->stu_master_stu_address_id = $stuAddress->stu_address_id;
                     $stuMaster->created_by = Yii::$app->getid->getId();
                     $stuMaster->created_at = new \yii\db\Expression('NOW()');
                     if ($stuMaster->save()) {
                         $stuInfo->stu_info_stu_master_id = $stuMaster->stu_master_id;
                         if ($stuInfo->save(false)) {
                             $auth_assign->item_name = 'Student';
                             $auth_assign->user_id = $user->user_id;
                             $auth_assign->created_at = date_format(date_create(), 'U');
                             $auth_assign->save(false);
                             $transaction->commit();
                             $totalSuccess += 1;
                             $dispResults[] = array_merge($line, ['type' => 'S', 'stuMasterId' => $stuMaster->stu_master_id, 'message' => 'Success']);
                         }
                     } else {
                         $dispResults[] = array_merge($line, ['type' => 'E', 'message' => Html::errorSummary($stuMaster)]);
                     }
                 }
                 // end stuInfo, user, StuAddress
                 $transaction->rollback();
             } catch (\Exception $e) {
                 $transaction->rollBack();
                 $dispResults[] = array_merge($line, ['type' => 'E', 'message' => $e->getMessage()]);
             }
         } else {
             $dispResults[] = array_merge($line, ['type' => 'E', 'message' => Html::errorSummary([$user, $stuInfo, $stuMaster, $stuAddress])]);
         }
         //end validated if
     }
     //end foreach
     return ['dispResults' => $dispResults, 'totalSuccess' => $totalSuccess];
 }
示例#17
0
 /**
  * @param $verification_code
  * @return Organization
  */
 public static function findByVerificationCodeOrFail($verification_code)
 {
     return Organization::where('verification_code', $verification_code)->firstOrFail();
 }
示例#18
0
 public function actionLoadimage()
 {
     $model = \app\models\Organization::find()->asArray()->all();
     header('Pragma: public');
     header('Expires: 0');
     header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
     header('Content-Transfer-Encoding: binary');
     header('Content-type: ' . $model[0]['org_logo_type']);
     echo $model[0]['org_logo'];
 }
示例#19
0
<html>
<head>
<title><?php 
echo $title;
?>
</title>
<link rel="stylesheet" type="text/css" href="<?php 
echo Yii::$app->request->baseUrl;
?>
/css/print-receipt.css" media="screen, print, projection" />
</head>
<body>

<div id="pcr">
<?php 
$orgData = \app\models\Organization::find()->asArray()->one();
?>

<table class="table table-bordered table-main">
	<tr>
		<td colspan=3 class="text-left padding-left padding-right" style="border-bottom:1px solid #000;height:80px">
		<table>
			<tr>
				<td rowspan=2><?php 
echo Html::img(Yii::$app->urlManager->createUrl('/site/loadimage'), ['style' => 'width:70px; height:50px']);
?>
</td>
				<td class="text-left org-title"><?php 
echo $orgData['org_name'];
?>
</td>
示例#20
0
 public function getOrgs()
 {
     return $this->hasMany(Organization::className(), ['id' => 'org_id'])->viaTable('country_org_rel', ['country_id' => 'id']);
 }
示例#21
0
 public function postOrganizationExcel(Request $request)
 {
     $ids = [1, 27];
     $organizations = \App\Models\Organization::where('type', 'client')->whereNotIn('id', $ids)->get();
     $year = $request->input('year');
     $quarters = $request->input('quarters');
     if (isset($quarters[1])) {
         $first = ' 1,';
     } else {
         $first = '';
     }
     if (isset($quarters[2])) {
         $second = ' 2,';
     } else {
         $second = '';
     }
     if (isset($quarters[3])) {
         $third = ' 3,';
     } else {
         $third = '';
     }
     if (isset($quarters[4])) {
         $fourth = ' 4';
     } else {
         $fourth = '';
     }
     $filename = 'Сводный отчет за ' . $year . ' год' . $first . $second . $third . $fourth . ' квартал';
     $file = Excel::create($filename, function ($excel) use($organizations, $year, $quarters) {
         $excel->getDefaultStyle()->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
         $excel->sheet('Сводный отчет', function ($sheet) use($organizations, $year, $quarters) {
             $min = min($quarters);
             $iterations = count($quarters);
             $sheet->setMergeColumn(array('columns' => array('A', 'B', 'C', 'D'), 'rows' => array(array(1, 2))));
             $sheet->row(1, ["№", "Организация", "ИНН", "Балансовая стоимость"]);
             $sheet->setWidth('B', 45);
             $sheet->setWidth('C', 13);
             $sheet->getStyle('A')->getAlignment()->applyFromArray(array('horizontal' => 'center'));
             $sheet->setWidth('D', 22);
             if ($iterations == 1) {
                 $number = 1;
                 $row = 3;
                 $sheet->getColumnDimension('E')->setAutoSize(true);
                 $sheet->mergeCells('E1:H1');
                 $sheet->setCellValue('E1', $min . ' квартал');
                 $sheet->mergeCells('I1:I2');
                 $sheet->setWidth('G', 23);
                 $sheet->setWidth('H', 23);
                 $sheet->setWidth('I', 23);
                 $sheet->fromArray(array(array('Статус', 'Износ', 'Приобретение', 'Списание')), null, 'E2', false, false);
                 $sheet->setCellValue('I1', 'Остаточная стоимость');
                 $sheet->cells('A1:I2', function ($cells) {
                     $cells->setAlignment('center');
                     $cells->setValignment('middle');
                 });
                 foreach ($organizations as $organization) {
                     $report = DB::table('reports')->whereOrganization_idAndYearAndQuarter($organization->id, $year, $min)->first();
                     $start = [$number, $organization->short_name, $organization->inn, isset($report->report_total_carrying_amount) ? $report->report_total_carrying_amount : 0];
                     $middle = $this->middle($report);
                     $end = [isset($report->report_wearout_residual_value) ? $report->report_wearout_residual_value : 0];
                     $sheet->row($row, array_merge($start, $middle, $end));
                     $row++;
                     $sheet->row($row, array('', 'Особоценное движимое имущество', ''));
                     $row++;
                     $sheet->row($row, array('', 'Автомобили', ''));
                     $row++;
                     $sheet->row($row, array('', 'Движимое имущество', ''));
                     $row++;
                     $sheet->row($row, array('', 'Здания и сооружения', ''));
                     $row++;
                     $sheet->row($row, array('', 'Земельные участки', ''));
                     $row++;
                     $number++;
                 }
             }
             if ($iterations == 2) {
                 $number = 1;
                 $row = 3;
                 $sheet->getColumnDimension('E')->setAutoSize(true);
                 $sheet->getColumnDimension('I')->setAutoSize(true);
                 $sheet->mergeCells('E1:H1');
                 $sheet->mergeCells('I1:L1');
                 $sheet->setCellValue('E1', $min . ' квартал');
                 $sheet->setCellValue('I1', $min + 1 . ' квартал');
                 $sheet->setWidth('G', 15);
                 $sheet->setWidth('H', 15);
                 $sheet->setWidth('I', 15);
                 $sheet->setWidth('J', 15);
                 $sheet->setWidth('K', 15);
                 $sheet->setWidth('L', 15);
                 $sheet->fromArray(array(array('Статус', 'Износ', 'Приобретение', 'Списание')), null, 'E2', false, false);
                 $sheet->fromArray(array(array('Статус', 'Износ', 'Приобретение', 'Списание')), null, 'I2', false, false);
                 $sheet->mergeCells('M1:M2');
                 $sheet->setWidth('M', 23);
                 $sheet->setCellValue('M1', 'Остаточная стоимость');
                 $sheet->cells('A1:M2', function ($cells) {
                     $cells->setAlignment('center');
                     $cells->setValignment('middle');
                 });
                 foreach ($organizations as $organization) {
                     $report = DB::table('reports')->whereOrganization_idAndYearAndQuarter($organization->id, $year, $min)->first();
                     $report1 = DB::table('reports')->whereOrganization_idAndYearAndQuarter($organization->id, $year, $min + 1)->first();
                     $start = [$number, $organization->short_name, $organization->inn, isset($report->report_total_carrying_amount) ? $report->report_total_carrying_amount : 0];
                     $middle = $this->middle($report);
                     $middle1 = $this->middle($report1);
                     $end = [isset($report1->report_wearout_residual_value) ? $report1->report_wearout_residual_value : 0];
                     $sheet->row($row, array_merge($start, $middle, $middle1, $end));
                     $row++;
                     $sheet->row($row, array('', 'Особоценное движимое имущество', ''));
                     $row++;
                     $sheet->row($row, array('', 'Автомобили', ''));
                     $row++;
                     $sheet->row($row, array('', 'Движимое имущество', ''));
                     $row++;
                     $sheet->row($row, array('', 'Здания и сооружения', ''));
                     $row++;
                     $sheet->row($row, array('', 'Земельные участки', ''));
                     $row++;
                     $number++;
                 }
             }
             if ($iterations == 3) {
                 $number = 1;
                 $row = 3;
                 $sheet->getColumnDimension('E')->setAutoSize(true);
                 $sheet->getColumnDimension('I')->setAutoSize(true);
                 $sheet->getColumnDimension('M')->setAutoSize(true);
                 $sheet->mergeCells('E1:H1');
                 $sheet->mergeCells('I1:L1');
                 $sheet->mergeCells('M1:P1');
                 $sheet->setCellValue('E1', $min . ' квартал');
                 $sheet->setCellValue('I1', $min + 1 . ' квартал');
                 $sheet->setCellValue('M1', $min + 2 . ' квартал');
                 $sheet->setWidth('G', 15);
                 $sheet->setWidth('H', 15);
                 $sheet->setWidth('I', 15);
                 $sheet->setWidth('J', 15);
                 $sheet->setWidth('K', 15);
                 $sheet->setWidth('L', 15);
                 $sheet->setWidth('N', 15);
                 $sheet->setWidth('O', 15);
                 $sheet->setWidth('P', 15);
                 $sheet->fromArray(array(array('Статус', 'Износ', 'Приобретение', 'Списание')), null, 'E2', false, false);
                 $sheet->fromArray(array(array('Статус', 'Износ', 'Приобретение', 'Списание')), null, 'I2', false, false);
                 $sheet->setCellValue('M2', 'Статус');
                 $sheet->setCellValue('N2', 'Износ');
                 $sheet->setCellValue('O2', 'Приобретение');
                 $sheet->setCellValue('P2', 'Списание');
                 $sheet->mergeCells('Q1:Q2');
                 $sheet->setWidth('Q', 23);
                 $sheet->setCellValue('Q1', 'Остаточная стоимость');
                 $sheet->cells('A1:Q2', function ($cells) {
                     $cells->setAlignment('center');
                     $cells->setValignment('middle');
                 });
                 foreach ($organizations as $organization) {
                     $report = DB::table('reports')->whereOrganization_idAndYearAndQuarter($organization->id, $year, $min)->first();
                     $report1 = DB::table('reports')->whereOrganization_idAndYearAndQuarter($organization->id, $year, $min + 1)->first();
                     $report2 = DB::table('reports')->whereOrganization_idAndYearAndQuarter($organization->id, $year, $min + 2)->first();
                     $start = [$number, $organization->short_name, $organization->inn, isset($report->report_total_carrying_amount) ? $report->report_total_carrying_amount : 0];
                     $middle = $this->middle($report);
                     $middle1 = $this->middle($report1);
                     $middle2 = $this->middle($report2);
                     $end = [isset($report2->report_wearout_residual_value) ? $report2->report_wearout_residual_value : 0];
                     $sheet->row($row, array_merge($start, $middle, $middle1, $middle2, $end));
                     $row++;
                     $sheet->row($row, array('', 'Особоценное движимое имущество', ''));
                     $row++;
                     $sheet->row($row, array('', 'Автомобили', ''));
                     $row++;
                     $sheet->row($row, array('', 'Движимое имущество', ''));
                     $row++;
                     $sheet->row($row, array('', 'Здания и сооружения', ''));
                     $row++;
                     $sheet->row($row, array('', 'Земельные участки', ''));
                     $row++;
                     $number++;
                 }
             }
             if ($iterations == 4) {
                 $number = 1;
                 $row = 3;
                 $sheet->getColumnDimension('E')->setAutoSize(true);
                 $sheet->getColumnDimension('I')->setAutoSize(true);
                 $sheet->getColumnDimension('M')->setAutoSize(true);
                 $sheet->getColumnDimension('Q')->setAutoSize(true);
                 $sheet->mergeCells('E1:H1');
                 $sheet->mergeCells('I1:L1');
                 $sheet->mergeCells('M1:P1');
                 $sheet->mergeCells('Q1:T1');
                 $sheet->setCellValue('E1', $min . ' квартал');
                 $sheet->setCellValue('I1', $min + 1 . ' квартал');
                 $sheet->setCellValue('M1', $min + 2 . ' квартал');
                 $sheet->setCellValue('Q1', $min + 3 . ' квартал');
                 $sheet->setWidth('G', 15);
                 $sheet->setWidth('H', 15);
                 $sheet->setWidth('I', 15);
                 $sheet->setWidth('J', 15);
                 $sheet->setWidth('K', 15);
                 $sheet->setWidth('L', 15);
                 $sheet->setWidth('N', 15);
                 $sheet->setWidth('O', 15);
                 $sheet->setWidth('P', 15);
                 $sheet->setWidth('R', 15);
                 $sheet->setWidth('S', 15);
                 $sheet->setWidth('T', 15);
                 $sheet->fromArray(array(array('Статус', 'Износ', 'Приобретение', 'Списание')), null, 'E2', false, false);
                 $sheet->fromArray(array(array('Статус', 'Износ', 'Приобретение', 'Списание')), null, 'I2', false, false);
                 $sheet->setCellValue('M2', 'Статус');
                 $sheet->setCellValue('N2', 'Износ');
                 $sheet->setCellValue('O2', 'Приобретение');
                 $sheet->setCellValue('P2', 'Списание');
                 $sheet->setCellValue('Q2', 'Статус');
                 $sheet->setCellValue('R2', 'Износ');
                 $sheet->setCellValue('S2', 'Приобретение');
                 $sheet->setCellValue('T2', 'Списание');
                 $sheet->mergeCells('U1:U2');
                 $sheet->setWidth('U', 23);
                 $sheet->setCellValue('U1', 'Остаточная стоимость');
                 $sheet->cells('A1:U2', function ($cells) {
                     $cells->setAlignment('center');
                     $cells->setValignment('middle');
                 });
                 foreach ($organizations as $organization) {
                     $report = DB::table('reports')->whereOrganization_idAndYearAndQuarter($organization->id, $year, $min)->first();
                     $report1 = DB::table('reports')->whereOrganization_idAndYearAndQuarter($organization->id, $year, $min + 1)->first();
                     $report2 = DB::table('reports')->whereOrganization_idAndYearAndQuarter($organization->id, $year, $min + 2)->first();
                     $report3 = DB::table('reports')->whereOrganization_idAndYearAndQuarter($organization->id, $year, $min + 3)->first();
                     $start = [$number, $organization->short_name, $organization->inn, isset($report->report_total_carrying_amount) ? $report->report_total_carrying_amount : 0];
                     $middle = $this->middle($report);
                     $middle1 = $this->middle($report1);
                     $middle2 = $this->middle($report2);
                     $middle3 = $this->middle($report3);
                     $end = [isset($report3->report_wearout_residual_value) ? $report3->report_wearout_residual_value : 0];
                     $sheet->row($row, array_merge($start, $middle, $middle1, $middle2, $middle3, $end));
                     $row++;
                     $sheet->row($row, array('', 'Особоценное движимое имущество', ''));
                     $row++;
                     $sheet->row($row, array('', 'Автомобили', ''));
                     $row++;
                     $sheet->row($row, array('', 'Движимое имущество', ''));
                     $row++;
                     $sheet->row($row, array('', 'Здания и сооружения', ''));
                     $row++;
                     $sheet->row($row, array('', 'Земельные участки', ''));
                     $row++;
                     $number++;
                 }
             }
         });
     })->store('xlsx', storage_path('excel/exports'), true);
     return Response::download($file['full']);
 }
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getOrg()
 {
     return $this->hasOne(Organization::className(), ['id' => 'org_id']);
 }
示例#23
0
 public function residueStore($id)
 {
     $organization = \App\Models\Organization::find($id);
     $residue = $organization->residue;
     if (isset($residue)) {
     } else {
         $residue = new \App\Models\Residue();
         $residue->organization_id = $id;
         $residue->state = 'not_accepted';
         $residue->save();
     }
     return redirect()->back();
 }
 /**
  * Finds the Organization model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Organization the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Organization::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
示例#25
0
        <div class="job-form">

            <?php 
$form = ActiveForm::begin();
?>

            <?php 
echo $form->field($model, 'title')->textarea(['rows' => 1]);
?>

            <?php 
echo $form->field($model, 'description')->textarea(['rows' => 4]);
?>

            <?php 
echo $form->field($model, 'org_id')->dropDownList(\app\models\Organization::getUserOrganizations(Yii::$app->user->id));
?>

            <?php 
echo $form->field($model, 'location')->textarea(['rows' => 1]);
?>

            <?php 
echo $form->field($model, 'start_date')->widget(DatePicker::classname(), ['model' => $model, 'attribute' => 'start_date', 'attribute2' => 'end_date', 'options' => ['placeholder' => 'Start date'], 'options2' => ['placeholder' => 'End date'], 'type' => DatePicker::TYPE_RANGE, 'form' => $form, 'pluginOptions' => ['autoclose' => true, 'format' => 'yyyy-mm-dd']]);
?>

            <?php 
echo $form->field($model, 'job_type')->dropDownList(Lookup::items('JobType'));
?>

            <?php 
 /**
  * @param $filter
  * @param $user
  *
  * @return array
  */
 public function getOrderList(&$filter, $subfilter, $user)
 {
     $orderModel = config('order.order_model');
     $q = $orderModel::with('proofOfTransfer', 'user', 'customer', 'proofOfTransfer.billplzResponses', 'orderStatus', 'orderItems', 'orderItems.product');
     if ($filter == 'draft' || $filter == 'unpaid') {
         $q = $q->where('order_status_id', '=', OrderStatus::Draft()->id);
     } else {
         $q = $q->where('order_status_id', '<>', OrderStatus::Draft()->id);
     }
     if ($subfilter == 'hq') {
         $q = $q->where('is_hq', '=', true)->where('organization_id', Organization::HQ()->id);
     } elseif ($subfilter == 'org') {
         $q = $q->where('is_hq', '=', false)->where('organization_id', $user->organization_id);
     } elseif ($subfilter == 'pl') {
         $q = $q->where('is_hq', '=', false)->where('organization_id', '<>', Organization::HQ()->id);
     } elseif ($subfilter == 'hq+org') {
         $q = $q->where('organization_id', '=', Organization::HQ()->id);
     } elseif ($subfilter == 'me') {
         $q = $q->where('user_id', '=', $user->id);
     }
     if ($filter == 'unapproved' || $filter == 'late-approvals') {
         $q = Order::whereNotApproved($q);
     } elseif ($filter == 'unfulfilled') {
         $q = Order::whereNotFulfilled($q);
     } elseif ($filter == 'fulfilled') {
         $q = Order::whereFulfilled($q);
     } elseif ($filter == 'approved') {
         $q = Order::whereNotFulfilled($q);
     } elseif ($filter == 'shipped') {
         $q = Order::whereShipped($q);
     }
     if ($user->access()->manager || $user->access()->staff) {
     }
     if ($filter == 'me' || $filter == 'down-line') {
         $userIds = User::userIdsForFilter($filter);
         $q = $q->whereIn('user_id', $userIds);
         return $q;
     } elseif ($user->access()->manager || $user->access()->staff) {
         if ($user->access()->staff) {
             $q = $q->where('created_at', '<=', 'DATE_SUB(CURDATE(), INTERVAL' . \Config::get('staff.canView') . ' ' . \Config::get('staff.system') . ')');
         }
         if ($filter == 'unapproved' || $filter == 'late-approvals') {
             $q = $q->where('created_at', '<=', 'DATE_SUB(CURDATE(), INTERVAL 1 WEEK)');
         }
         return $q;
     } else {
         return $q;
     }
 }
 /**
  * Ruturn institute-setup page if application is no-institute found.
  * @return mixed
  */
 public function actionInstituteSetup()
 {
     $chkInstituteTbl = \app\models\Organization::find()->exists();
     if ($chkInstituteTbl) {
         return $this->redirect(['user-setup']);
     }
     $model = new \app\models\Organization();
     $model->scenario = 'insert';
     if (isset($_POST['Organization']) && $model->load(Yii::$app->request->post())) {
         $image_string = null;
         $model->attributes = $_POST['Organization'];
         $model->org_email = strtolower($_POST['Organization']['org_email']);
         $model->created_at = new \yii\db\Expression('NOW()');
         ob_start();
         if (!empty($_FILES['Organization']['tmp_name']['org_logo'])) {
             $file = UploadedFile::getInstance($model, 'org_logo');
             $model->org_logo_type = $file->type;
             $fp = fopen($file->tempName, 'r');
             $content = fread($fp, filesize($file->tempName));
             fclose($fp);
             if ($model->org_logo_type == "image/png") {
                 $src_img = imagecreatefrompng($file->tempName);
                 $dst_img = imagecreatetruecolor(90, 70);
                 imagealphablending($dst_img, false);
                 imagesavealpha($dst_img, true);
                 $transparent = imagecolorallocatealpha($dst_img, 255, 255, 255, 127);
                 imagefilledrectangle($dst_img, 0, 0, 90, 70, $transparent);
                 imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, 90, 70, imagesx($src_img), imagesy($src_img));
                 imagepng($dst_img);
                 ob_start();
                 imagepng($dst_img);
                 $image_string = ob_get_contents();
                 ob_end_flush();
             }
             if ($model->org_logo_type == "image/jpg" || $model->org_logo_type == "image/jpeg") {
                 $src_img = imagecreatefromjpeg($file->tempName);
                 $dst_img = imagecreatetruecolor(90, 70);
                 imagealphablending($dst_img, false);
                 imagesavealpha($dst_img, true);
                 $transparent = imagecolorallocatealpha($dst_img, 255, 255, 255, 127);
                 imagefilledrectangle($dst_img, 0, 0, 90, 70, $transparent);
                 imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, 90, 70, imagesx($src_img), imagesy($src_img));
                 imagejpeg($dst_img);
                 ob_start();
                 imagepng($dst_img);
                 $image_string = ob_get_contents();
                 ob_end_flush();
             }
             if ($model->org_logo_type == "image/gif") {
                 $src_img = imagecreatefromgif($file->tempName);
                 $dst_img = imagecreatetruecolor(90, 70);
                 imagealphablending($dst_img, false);
                 imagesavealpha($dst_img, true);
                 $transparent = imagecolorallocatealpha($dst_img, 255, 255, 255, 127);
                 imagefilledrectangle($dst_img, 0, 0, 90, 70, $transparent);
                 imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, 90, 70, imagesx($src_img), imagesy($src_img));
                 imagepng($dst_img);
                 ob_start();
                 imagecreatefromgif($dst_img);
                 $image_string = ob_get_contents();
                 ob_end_flush();
             }
             $model->org_logo = $image_string;
         }
         if ($model->save()) {
             return $this->redirect(['user-setup']);
         }
     }
     return $this->render('institute-setup', ['model' => $model]);
 }
示例#28
0
 /**
  * Creates a new StuMaster model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new StuMaster();
     $info = new StuInfo();
     $address = new StuAddress();
     $user = new User();
     $auth_assign = new AuthAssignment();
     if (Yii::$app->request->isAjax) {
         if ($info->load(Yii::$app->request->post())) {
             \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
             return ActiveForm::validate($info);
         }
         if ($model->load(Yii::$app->request->post())) {
             \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
             return ActiveForm::validate($model);
         }
     }
     $stud_uniq_no = \app\modules\student\models\StuInfo::find()->max('stu_unique_id');
     $uniq_id = NULL;
     if (empty($stud_uniq_no)) {
         $uniq_id = $info->stu_unique_id = 1;
     } else {
         $chk_id = StuInfo::find()->where(['stu_unique_id' => $stud_uniq_no])->exists();
         if ($chk_id) {
             $uniq_id = $stud_uniq_no + 1;
         } else {
             $uniq_id = $stud_uniq_no;
         }
     }
     if ($model->load(Yii::$app->request->post()) || $info->load(Yii::$app->request->post())) {
         $login_id = \app\models\Organization::find()->one()->org_stu_prefix . $uniq_id;
         $model->attributes = $_POST['StuMaster'];
         $info->attributes = $_POST['StuInfo'];
         $info->stu_dob = Yii::$app->dateformatter->getDateFormat($_POST['StuInfo']['stu_dob']);
         $info->stu_admission_date = Yii::$app->dateformatter->getDateFormat($_POST['StuInfo']['stu_admission_date']);
         if (empty($_POST['StuInfo']['stu_email_id'])) {
             $info->stu_email_id = NULL;
         } else {
             $info->stu_email_id = strtolower($_POST['StuInfo']['stu_email_id']);
         }
         $user->user_login_id = $login_id;
         $user->user_password = md5($user->user_login_id . $user->user_login_id);
         $user->user_type = "S";
         $user->created_by = Yii::$app->getid->getId();
         $user->created_at = new \yii\db\Expression('NOW()');
         if ($info->save(false)) {
             $user->save(false);
             $address->save(false);
         }
         $model->stu_master_stu_address_id = $address->stu_address_id;
         $model->stu_master_stu_info_id = $info->stu_info_id;
         $model->stu_master_user_id = $user->user_id;
         $model->created_by = Yii::$app->getid->getId();
         $model->created_at = new \yii\db\Expression('NOW()');
         $model->save(false);
         $s_info = StuInfo::findOne($model->stu_master_stu_info_id);
         $s_info->stu_info_stu_master_id = $model->stu_master_id;
         $s_info->save(false);
         $auth_assign->item_name = 'Student';
         $auth_assign->user_id = $user->user_id;
         $auth_assign->created_at = date_format(date_create(), 'U');
         $auth_assign->save(false);
         if ($model->save()) {
             return $this->redirect(['view', 'id' => $model->stu_master_id]);
         } else {
             return $this->render('create', ['model' => $model, 'info' => $info, 'uniq_id' => $uniq_id]);
         }
     } else {
         return $this->render('create', ['model' => $model, 'info' => $info, 'uniq_id' => $uniq_id]);
     }
 }
 public function getOne($organization_id)
 {
     $organization = Organization::findOrFailCached($organization_id);
     return $this->api->organizations($organization)->defaultAction($this->request->all());
 }
示例#30
0
 public function AddForAll()
 {
     $organizations = \App\Models\Organization::all();
     foreach ($organizations as $organization) {
         $id = $organization->id;
         $reports = $organization->reports;
         if ($reports->count()) {
             $maxYear = \App\Models\Report::where('organization_id', '=', $id)->max('year');
             $maxQuarter = \App\Models\Report::where('organization_id', '=', $id)->where('year', '=', $maxYear)->max('quarter');
             if ($maxQuarter == 4 && $maxYear != 2016) {
                 $year = ++$maxYear;
                 $report = new \App\Models\Report();
                 $report->year = $year;
                 $report->quarter = 1;
                 $report->organization_id = $id;
                 $report->state = 'not_accepted';
                 $report->save();
             } elseif ($maxQuarter != 4) {
                 $quarter = $maxQuarter + 1;
                 $report = new \App\Models\Report();
                 $report->year = $maxYear;
                 $report->quarter = $quarter;
                 $report->organization_id = $id;
                 $report->state = 'not_accepted';
                 $report->save();
             }
         } else {
             $report = new \App\Models\Report();
             $report->year = 2015;
             $report->quarter = 1;
             $report->organization_id = $id;
             $report->state = 'not_accepted';
             $report->save();
         }
     }
     return redirect()->back();
 }