Example #1
0
 /**
  * Displays a map of all open tickets
  * @return mixed
  */
 public function actionMap()
 {
     $tickets = ArrayHelper::map(Ticket::find()->active()->all(), 'id', 'fullName', 'invoice_id');
     $locations = Location::find()->where(['id' => array_keys($tickets)])->with('client')->all();
     Url::remember();
     return $this->render('map', ['locations' => $locations, 'tickets' => $tickets]);
 }
Example #2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Location::find()->joinWith('client')->andWhere([Client::tableName() . '.active' => true]);
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => false, 'sort' => ['defaultOrder' => ['client_id' => SORT_ASC, 'name' => SORT_ASC]]]);
     $dataProvider->sort->attributes['client_id'] = ['asc' => [Client::tableName() . '.name' => SORT_ASC], 'desc' => [Client::tableName() . '.name' => SORT_DESC]];
     if (Yii::$app->user->can('Accounting')) {
         $query->joinWith('lastInvoice');
         $dataProvider->sort->attributes['lastInvoiceStatus'] = ['asc' => [Invoice::tableName() . '.status_id' => SORT_ASC], 'desc' => [Invoice::tableName() . '.status_id' => SORT_DESC]];
     }
     $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([self::tableName() . '.client_id' => $this->client_id, self::tableName() . '.proactive' => $this->proactive, self::tableName() . '.active' => $this->active]);
     if (Yii::$app->user->can('Accounting')) {
         $query->andFilterWhere([Invoice::tableName() . '.status_id' => $this->lastInvoiceStatus]);
     }
     $query->andFilterWhere(['or', ['like', self::tableName() . '.name', $this->name], ['like', Client::tableName() . '.name', $this->name]])->andFilterWhere(['like', 'phone', $this->phone]);
     return $dataProvider;
 }
Example #3
0
$form = ActiveForm::begin(['layout' => 'horizontal']);
?>

    <div>
        <?php 
echo $form->errorSummary($model);
?>
        <?php 
$this->beginBlock('main');
?>
        <p>
            <?php 
/*= $form->field($model, 'invoice_id')->dropDownList(yii\helpers\ArrayHelper::map(\common\models\Location::find()->active()->all(), 'id', 'fullName'), ['id' => 'location-select','prompt' => '']) */
?>
            <?php 
echo $form->field($model, 'invoice_id')->widget(\kartik\select2\Select2::className(), ['data' => \yii\helpers\ArrayHelper::map(\common\models\Location::find()->active()->all(), 'id', 'fullName'), 'options' => ['prompt' => '', 'id' => 'location-select']]);
?>

            <?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 Html::a('<span class="glyphicon glyphicon-plus"></span> New Ticket', ['ticket/create', 'close' => true, 'Ticket' => ['invoice_id' => $model->invoice_id]], ['id' => 'new-ticket-btn', 'class' => 'btn btn-success btn-xs pull-right', 'target' => '_blank']);
?>
            <?php 
echo Html::button('<span class="glyphicon glyphicon-refresh"></span>', ['class' => 'btn btn-default btn-xs pull-right', 'title' => 'Refresh tickets for selected location', 'onclick' => '$("#location-select").trigger("depdrop.change")']);
?>
            <?php 
echo $form->field($model, 'ticketIds')->widget(\kartik\depdrop\DepDrop::className(), ['type' => \kartik\depdrop\DepDrop::TYPE_SELECT2, 'data' => yii\helpers\ArrayHelper::map(\common\models\Ticket::find()->location($model->invoice_id)->open()->all(), 'id', 'fullName'), 'options' => ['multiple' => true], 'select2Options' => ['pluginOptions' => ['allowClear' => true]], 'pluginOptions' => ['depends' => ['location-select'], 'url' => Url::to(['/location/ajax-tickets']), 'placeholder' => false], 'pluginEvents' => ['depdrop.change' => 'function(event, id, value, count) {
                        console.log(event, id, value);
Example #4
0
<?php

use yii\helpers\Html;
use yii\grid\GridView;
use yii\widgets\Pjax;
/* @var $this yii\web\View */
/* @var $searchModel frontend\models\InvoiceSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = 'Invoices';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="invoice-index">

    <h3><?php 
echo Html::encode($this->title);
?>
</h3>

    <?php 
Pjax::begin(['id' => 'invoices-pjax', 'linkSelector' => '#invoices-pjax a[data-sort]', 'enablePushState' => !Yii::$app->request->isAjax]);
?>
    <?php 
echo GridView::widget(['id' => 'invoices-grid', 'dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['attribute' => 'id', 'value' => 'idNum'], ['attribute' => 'location_id', 'value' => 'location.fullName', 'filter' => \yii\helpers\ArrayHelper::map(\common\models\Location::find()->active()->all(), 'id', 'fullName')], ['attribute' => 'status_id', 'value' => 'status', 'filter' => $searchModel::$STATUSES], ['class' => 'yii\\grid\\ActionColumn', 'template' => '{view}', 'buttonOptions' => ['class' => 'showModalButton']]]]);
?>
    <?php 
Pjax::end();
?>

</div>
Example #5
0
$this->title = 'Tickets';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="ticket-index">
    <p class="pull-right">
        <?php 
echo Html::a('<span class="glyphicon glyphicon-map-marker"></span> Map', ['map'], ['class' => 'btn btn-info btn-xs']);
?>
        <?php 
echo Html::a('<span class="glyphicon glyphicon-plus"></span> New Ticket', ['create'], ['class' => 'btn btn-success btn-xs showModalButton']);
?>
    </p>
    <h3><?php 
echo Html::encode($this->title);
?>
</h3>

    <?php 
Pjax::begin(['id' => 'tickets-pjax', 'linkSelector' => '#tickets-pjax a[data-sort]', 'enablePushState' => !Yii::$app->request->isAjax]);
?>
    <?php 
echo GridView::widget(['id' => 'tickets-grid', 'dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['attribute' => 'location_id', 'label' => 'Location', 'value' => 'invoice.location.fullName', 'filter' => \yii\helpers\ArrayHelper::map(\common\models\Location::find()->active()->all(), 'id', 'fullName')], ['attribute' => 'id', 'format' => 'raw', 'value' => function ($m) {
    /** @var \common\models\Ticket $m */
    return Html::a($m->fullName, ['view', 'id' => $m->id]);
}, 'headerOptions' => ['class' => 'primary'], 'filterInputOptions' => ['placeholder' => '(TT# or Title)', 'class' => 'form-control']], ['attribute' => 'status_id', 'value' => 'status', 'filter' => $searchModel::$STATUSES], ['attribute' => 'priority_id', 'value' => 'priority', 'filter' => $searchModel::$PRIORITIES], ['attribute' => 'bill_type_id', 'value' => 'billType', 'filter' => $searchModel::$BILL_TYPE_SELECT], ['class' => 'yii\\grid\\ActionColumn', 'template' => '{view}', 'buttonOptions' => ['class' => 'showModalButton']]]]);
?>
    <?php 
Pjax::end();
?>

</div>
Example #6
0
<div class="schedule-form">

    <?php 
$form = ActiveForm::begin(['layout' => 'horizontal']);
?>

    <div>
        <?php 
echo $form->errorSummary([$model, $note, $ticket]);
?>
        <?php 
$this->beginBlock('main');
?>
        <p>
            <?php 
echo $form->field($model, 'invoice_id')->widget(Select2::className(), ['data' => yii\helpers\ArrayHelper::map(\common\models\Location::find()->active()->all(), 'id', 'fullName'), 'options' => ['placeholder' => '', 'id' => 'location-select'], 'pluginOptions' => ['allowClear' => true]]);
?>

            <?php 
echo $form->field($note, 'body')->label('Notes')->textarea(['rows' => 12]);
?>

            <?php 
echo $form->field($model, 'start_time')->widget(DateTimePicker::className(), ['disabled' => $remote, 'pluginOptions' => ['format' => 'yyyy-mm-dd hh:ii:00', 'startDate' => date('Y-m-d', strtotime('-1 month')), 'initialDate' => date('Y-m-d H:00:00', strtotime('+1 hour')), 'todayHighlight' => true, 'showMeridian' => true, 'minuteStep' => 15, 'autoclose' => true]]);
?>

            <?php 
echo $form->field($model, 'duration')->input('number', ['min' => 15, 'step' => 5]);
?>

        </p>