コード例 #1
0
ファイル: LoginForm.php プロジェクト: jslight/helpdesk
 /**
  * Logs in a user using the provided username and password.
  *
  * @return boolean whether the user is logged in successfully
  */
 public function login()
 {
     if ($this->validate() && Yii::$app->user->login($this->getUser(), $this->rememberMe ? 3600 * 24 * 30 : 0)) {
         $user = Yii::$app->user;
         if ($user->identity->className() == Tech::className() && $user->identity->reload_roles) {
             MenuHelper::invalidate();
             $user->identity->reload_roles = false;
             $user->identity->save(false);
         }
         return true;
     } else {
         return false;
     }
 }
コード例 #2
0
ファイル: TechSearch.php プロジェクト: jslight/helpdesk
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Tech::find()->joinWith('contact');
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $dataProvider->sort->attributes['username'] = ['asc' => [Contact::tableName() . '.email' => SORT_ASC], 'desc' => [Contact::tableName() . '.email' => SORT_DESC]];
     $dataProvider->sort->attributes['name'] = ['asc' => [Contact::tableName() . '.name' => SORT_ASC], 'desc' => [Contact::tableName() . '.name' => SORT_DESC]];
     $dataProvider->sort->defaultOrder = ['name' => SORT_ASC];
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere([Tech::tableName() . '.contact_id' => $this->id]);
     $query->andFilterWhere(['like', Contact::tableName() . '.email', $this->username])->andFilterWhere(['like', Contact::tableName() . '.name', $this->name]);
     return $dataProvider;
 }
コード例 #3
0
 /**
  * Lists all Schedule models.
  * @return mixed
  */
 public function actionIndex()
 {
     Url::remember();
     return $this->render('index', ['techs' => Tech::find()->hasCalendar()->contact()->all()]);
 }
コード例 #4
0
ファイル: _form.php プロジェクト: jslight/helpdesk
<div class="reimbursement-form">

    <?php 
$form = ActiveForm::begin(['layout' => 'horizontal', 'options' => ['enctype' => 'multipart/form-data']]);
?>

    <div>
        <?php 
echo $form->errorSummary($model);
?>
        <?php 
$this->beginBlock('main');
?>
        <p>
            <?php 
echo $form->field($model, 'tech_id')->dropDownList(\yii\helpers\ArrayHelper::map(\common\models\Tech::find()->contact()->all(), 'contact_id', 'contact.name'), ['prompt' => '']);
?>

            <?php 
echo $form->field($model, 'amount')->textInput(['maxlength' => true]);
?>

            <?php 
echo $form->field($model, 'receiptImg')->widget(\kartik\file\FileInput::className(), ['options' => ['accept' => 'image/*,text/*,application/pdf'], 'pluginOptions' => ['browseClass' => 'btn btn-info btn-xs', 'showCaption' => false, 'showRemove' => false, 'showUpload' => false, 'initialPreview' => [$model->isNewRecord ? null : Yii::$app->formatter->asFile($model, ['receipt', 'id' => $model->id])]]]);
?>

        </p>
        <?php 
$this->endBlock();
?>
コード例 #5
0
ファイル: Contact.php プロジェクト: jslight/helpdesk
 /**
  * @return string
  */
 public function getUserClass()
 {
     if (!$this->_userClass) {
         $this->_userClass = $this->client_id === Client::MASTER_ID ? Tech::className() : User::className();
     }
     return $this->_userClass;
 }
コード例 #6
0
ファイル: TechController.php プロジェクト: jslight/helpdesk
 /**
  * Finds the Tech model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Tech the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Tech::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
コード例 #7
0
ファイル: Tech.php プロジェクト: jslight/helpdesk
 /**
  * @inheritdoc
  */
 public function rules()
 {
     return [[['contact_id', 'startTime', 'endTime', 'roles'], 'required'], [['contact_id'], 'integer'], [['password'], 'string', 'min' => 6, 'max' => 32], [['confirm_password'], 'compare', 'compareAttribute' => 'password'], [['start_of_day', 'end_of_day'], 'date', 'format' => 'HH:mm'], [['end_of_day'], 'compare', 'operator' => '>', 'compareAttribute' => 'start_of_day'], [['roles'], 'each', 'rule' => ['string']], [['contact_id'], 'exist', 'targetClass' => Contact::className(), 'targetAttribute' => 'id'], [['contact_id'], 'unique', 'targetClass' => Tech::className(), 'message' => 'This user already has an account.'], [['roles'], 'each', 'rule' => ['in', 'range' => ArrayHelper::getColumn(Yii::$app->authManager->getRoles(), 'name')]]];
 }
コード例 #8
0
ファイル: Schedule.php プロジェクト: jslight/helpdesk
 /**
  * @inheritdoc
  */
 public function rules()
 {
     return [[['invoice_id', 'tech_id', 'start_time', 'duration', 'ticketIds'], 'required', 'on' => self::SCENARIO_DEFAULT], [['invoice_id', 'start_time', 'duration'], 'required', 'on' => self::SCENARIO_REMOTE], [['invoice_id', 'tech_id'], 'integer'], [['onSite'], 'boolean'], [['start_time'], 'date', 'format' => 'yyyy-MM-dd HH:mm:ss'], [['duration'], 'integer', 'min' => '15'], [['description'], 'string'], [['ticketIds'], 'each', 'rule' => ['integer']], [['invoice_id'], 'exist', 'targetClass' => Location::className(), 'targetAttribute' => 'id'], [['tech_id'], 'exist', 'targetClass' => Tech::className(), 'targetAttribute' => 'contact_id'], [['ticketIds'], 'each', 'rule' => ['exist', 'targetClass' => Ticket::className(), 'targetAttribute' => 'id']]];
 }
コード例 #9
0
ファイル: Subscription.php プロジェクト: jslight/helpdesk
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getTech()
 {
     return $this->hasOne(Tech::className(), ['contact_id' => 'tech_id']);
 }
コード例 #10
0
ファイル: PurchasedItem.php プロジェクト: jslight/helpdesk
 /**
  * @inheritdoc
  */
 public function rules()
 {
     return [[['ticket_id', 'item_name', 'item_type_id', 'cost', 'added_by'], 'required'], [['ticket_id', 'item_type_id', 'quantity', 'added_by'], 'integer'], [['cost'], 'number'], [['item_name'], 'string', 'max' => 120], [['item_type_id'], 'in', 'range' => array_keys(self::$ITEM_TYPES)], [['ticket_id'], 'exist', 'targetClass' => Ticket::className(), 'targetAttribute' => 'id'], [['added_by'], 'exist', 'targetClass' => Tech::className(), 'targetAttribute' => 'contact_id']];
 }