/**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Receipt::find();
     $query->joinWith(['estimate']);
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $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(['receipt.id' => $this->id, 'receipt.estimate_id' => $this->estimate_id, 'receipt.status' => $this->status, 'receipt.created_date' => $this->created_date, 'receipt.type' => $this->type, 'receipt.iva' => $this->iva, 'estimate.client_id' => $this->client_id]);
     $query->andFilterWhere(['like', 'number', $this->number]);
     /**
      * Convert the to dates to mysql format.
      * Leave them as null so they are not used
      * by ActiveQuery::andFilterWhere().
      */
     $fromDate = null;
     $toDate = null;
     if ($this->from_date) {
         $this->from_date = DateConverter::convert($this->from_date);
     }
     if ($this->to_date) {
         $this->to_date = DateConverter::convert($this->to_date);
     }
     $query->andFilterWhere(['>=', 'created_date', $this->from_date]);
     $query->andFilterWhere(['<=', 'created_date', $this->to_date]);
     return $dataProvider;
 }
Beispiel #2
0
 /**
  * @return \Illuminate\Routing\Route|null|string
  */
 public function ingnoreId()
 {
     $id = $this->route('receipt');
     $commodity_id = $this->input('commodity_id');
     $supplier_id = $this->input('supplier_id');
     $user_id = $this->input('user_id');
     return Receipt::where(compact('id', 'commodity_id', 'supplier_id', 'user_id'))->exists() ? $id : '';
 }
Beispiel #3
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function delete($id)
 {
     //Soft delete the patient
     $receipt = Receipt::find($id);
     $receipt->delete();
     // redirect
     return redirect()->to('receipt.index')->with('message', trans('messages.receipt-succesfully-deleted'));
 }
Beispiel #4
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     //
     $issue = Issue::find($id);
     $commodities = Commodity::all()->lists('name', 'id');
     $batches = Receipt::all()->lists('batch_no', 'id');
     $users = User::where('id', '!=', Auth::user()->id)->lists('name', 'id');
     $sections = TestCategory::all()->lists('name', 'id');
     //To DO:create function for this
     $available = $issue->topupRequest->commodity->available();
     return view('issue.edit')->with('commodities', $commodities)->with('available', $available)->with('users', $users)->with('sections', $sections)->with('issue', $issue)->with('batches', $batches);
 }
Beispiel #5
0
 public function stockLevel()
 {
     //  Fetch form filters
     $date = date('Y-m-d');
     $from = Input::get('start');
     if (!$from) {
         $from = date('Y-m-01');
     }
     $to = Input::get('end');
     if (!$to) {
         $to = $date;
     }
     $reportTypes = array('Monthly', 'Quarterly');
     $selectedReport = Input::get('report_type');
     if (!$selectedReport) {
         $selectedReport = 0;
     }
     switch ($selectedReport) {
         case '0':
             $reportData = Receipt::getIssuedCommodities($from, $to . ' 23:59:59');
             $reportTitle = Lang::choice('messages.monthly-stock-level-report-title', 1);
             break;
         case '1':
             $reportData = Receipt::getIssuedCommodities($from, $to . ' 23:59:59');
             $reportTitle = Lang::choice('messages.quarterly-stock-level-report-title', 1);
             break;
         default:
             $reportData = Receipt::getIssuedCommodities($from, $to . ' 23:59:59');
             $reportTitle = Lang::choice('messages.monthly-stock-level-report-title', 1);
             break;
     }
     $reportTitle = str_replace("[FROM]", $from, $reportTitle);
     $reportTitle = str_replace("[TO]", $to, $reportTitle);
     return view('reports.inventory.index')->with('reportTypes', $reportTypes)->with('reportData', $reportData)->with('reportTitle', $reportTitle)->with('selectedReport', $selectedReport)->withInput(Input::all());
 }
Beispiel #6
0
<div class="receipt-form">

    <?php 
$form = ActiveForm::begin();
?>
	
	<?php 
echo $form->field($model, 'number')->textInput();
?>
	
	<?php 
echo $form->field($model, 'type')->textInput()->dropDownList(Receipt::typeLabels());
?>

    <?php 
echo $form->field($model, 'status')->dropDownList(Receipt::statusLabels());
?>

    <div class="form-group">
        <?php 
echo Html::submitButton($model->isNewRecord ? 'Crear' : 'Editar', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
    </div>

    <?php 
ActiveForm::end();
?>

</div>
Beispiel #7
0
	<?php 
ActiveForm::end();
?>

</div>

<div class="receipt-index">

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

	<?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['attribute' => 'id', 'options' => ['style' => 'width: 100px;']], ['label' => 'Cliente', 'value' => 'estimate.client.name', 'filter' => Html::activeDropDownList($searchModel, 'client_id', Client::getIdNameArray(), ['class' => 'form-control', 'prompt' => 'Nombre'])], ['label' => 'Presupuesto', 'value' => 'estimate.title'], 'number', ['class' => 'kartik\\grid\\EditableColumn', 'attribute' => 'status', 'label' => 'Estado', 'value' => 'statusLabel', 'filter' => Html::activeDropDownList($searchModel, 'status', Receipt::statusLabels(), ['class' => 'form-control', 'prompt' => 'Estado']), 'editableOptions' => ['inputType' => Editable::INPUT_DROPDOWN_LIST, 'data' => Receipt::statusLabels()]], ['attribute' => 'created_date', 'format' => 'date', 'filter' => false], ['class' => 'yii\\grid\\ActionColumn']]]);
?>

	<?php 
echo ExportMenu::widget(['dataProvider' => $exportDataProvider, 'target' => ExportMenu::TARGET_SELF, 'showConfirmAlert' => false, 'filename' => 'facturas', 'columns' => [['attribute' => 'created_date', 'format' => 'date', 'filter' => false], ['attribute' => 'type', 'value' => 'typeLabel'], ['attribute' => 'number', 'label' => 'Factura Nro'], ['label' => 'Cliente', 'value' => 'estimate.client.name'], ['label' => 'CUIT', 'value' => 'estimate.client.cuit'], ['label' => 'Facturación Neta', 'value' => function ($model, $key, $index, $column) {
    return Currency::format($model->estimate->total_checked, Currency::CURRENCY_ARS);
}], ['label' => 'IVA', 'value' => function ($model, $key, $index, $column) {
    return Currency::format($model->IVATotal, Currency::CURRENCY_ARS);
}], ['label' => 'Facturación Bruta', 'value' => function ($model, $key, $index, $column) {
    return Currency::format($model->gross, Currency::CURRENCY_ARS);
}], ['label' => 'Utilidad', 'value' => function ($model, $key, $index, $column) {
    return Currency::format($model->estimate->total_checked - $model->estimate->cost_checked, Currency::CURRENCY_ARS);
}], ['label' => 'Porcentaje', 'value' => null], ['label' => 'Productos', 'value' => 'products'], ['label' => 'Estado', 'value' => 'statusLabel'], ['label' => 'Recibo Nro', 'value' => null]]]);
?>

</div>
Beispiel #8
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getReceipt()
 {
     return $this->hasOne(Receipt::className(), ['estimate_id' => 'id']);
 }
 /**
  * Finds the Receipt model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Receipt the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Receipt::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }