Ejemplo n.º 1
0
 /**
  * Delete package.
  * @param  [int] $package_id [description]
  * @return [type]             [description]
  */
 public function deletePackage($package_id)
 {
     $extras = Extra::where('package_id', $package_id)->get();
     foreach ($extras as $key => $value) {
         Extrafile::where('extra_id', $value->id)->where('is_attached', 1)->delete();
         Extra::find($value->id)->delete();
     }
     Package::find($package_id)->delete();
 }
Ejemplo n.º 2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Package::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['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(['id' => $this->id, 'store_id' => $this->store_id, 'order_id' => $this->order_id, 'order_date' => $this->order_date, 'courier_id' => $this->courier_id, 'shipment_date' => $this->shipment_date, 'delivery_date' => $this->delivery_date, 'arrived_in' => $this->arrived_in, 'is_disputed' => $this->is_disputed, 'created_by' => $this->created_by, 'created_at' => $this->created_at, 'updated_by' => $this->updated_by, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'price', $this->price])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'tracking_id', $this->tracking_id])->andFilterWhere(['like', 'paid_with', $this->paid_with])->andFilterWhere(['like', 'refund_status', $this->refund_status])->andFilterWhere(['like', 'status', $this->status])->andFilterWhere(['like', 'notes', $this->notes]);
     return $dataProvider;
 }
Ejemplo n.º 3
0
 /**
  * Retrieves all appointments and returns them
  * in fullCalendar expected JSON
  */
 public function GetAllAppointments()
 {
     $appointments = Appointment::all();
     $calendarAppointments = array();
     foreach ($appointments as $a) {
         $customer = Customer::find($a['customer_id']);
         $customer = $customer->first_name . ' ' . $customer->last_name;
         $package = Package::find($a['appointment_type']);
         $startDate = date_create($a['appointment_datetime']);
         $endDate = date_create($a['appointment_datetime']);
         $time = (string) $package->package_time . ' hours';
         $endDate = date_add($endDate, date_interval_create_from_date_string($time));
         $event = array('id' => $a['id'], 'title' => 'Appointment with ' . $customer, 'start' => $startDate->format('Y-m-d\\TH:i:s'), 'end' => $endDate->format('Y-m-d\\TH:i:s'));
         array_push($calendarAppointments, $event);
     }
     return response()->json($calendarAppointments);
 }
Ejemplo n.º 4
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $package = \App\Models\Package::find($id);
     $package->delete();
     return redirect('pricingPackages');
 }
Ejemplo n.º 5
0
echo Html::a('New', ['create'], ['class' => 'btn btn-success']);
?>
        <?php 
echo Html::a('Update', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']);
?>
        <?php 
echo Html::a('Delete', ['delete', 'id' => $model->id], ['class' => 'btn btn-danger', 'data' => ['confirm' => 'Are you sure you want to delete this item?', 'method' => 'post']]);
?>
        <?php 
echo Html::a('Import Store', ['import'], ['class' => 'btn btn-warning']);
?>
    </p>

    <?php 
echo DetailView::widget(['model' => $model, 'attributes' => ['id', ['attribute' => 'store_number', 'value' => empty($model->store_number) ? "<i>N/A</i>" : $model->store_number . " [" . Html::a('AliExpress Store Page', 'http://www.aliexpress.com/store/' . $model->store_number, array('target' => '_blank')) . "]", 'format' => 'raw'], 'name', 'location', 'since', 'notes:ntext', ['attribute' => 'created_by', 'value' => $model->createdByUser->username, 'format' => 'text'], 'created_at', ['attribute' => 'updated_by', 'value' => $model->updatedByUser->username, 'format' => 'text'], 'updated_at']]);
?>

    <?php 
$dataProvider = new ActiveDataProvider(['query' => \app\models\Package::find()->innerJoin('store', '`store`.`id` = `package`.`store_id`')->where(['store.id' => $model->id])->with('store')->orderBy('id DESC'), 'pagination' => ['pageSize' => -1]]);
echo GridView::widget(['dataProvider' => $dataProvider, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'order_id', 'description', 'price', 'order_date', 'shipment_date', 'delivery_date', 'is_disputed', ['attribute' => 'status', 'value' => function ($model) {
    return "<b style='color:red;'>" . $model->status . "</b>";
}, 'format' => 'raw'], ['class' => 'yii\\grid\\ActionColumn', 'contentOptions' => ['style' => 'width:70px;'], 'header' => 'Actions', 'template' => '{view}', 'urlCreator' => function ($action, $model, $key, $index) {
    if ($action === 'view') {
        $url = '/package/view/' . $model->id;
        return $url;
    }
}]]]);
?>

</div>
Ejemplo n.º 6
0
 /**
  * View Function to edit package information
  * @param  int $package_id
  * @return view
  */
 public function editPackage($package_id)
 {
     return view('admin/packages/editPackage', ['package' => Package::find($package_id)]);
 }
Ejemplo n.º 7
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     $this->validation_rules($request);
     $packageUpdate = $request->input();
     $package = Package::find($id);
     $package->update($packageUpdate);
     Session::flash('flash_message', 'Data Paket layanan berhasil diupdate!');
     return redirect('admin/package');
 }
Ejemplo n.º 8
0
?>

    <?php 
$dataProvider = new ActiveDataProvider(['query' => \app\models\Package::find()->innerJoin('courier', '`courier`.`id` = `package`.`courier_id`')->where(['courier.id' => $model->id])->orderBy('id DESC'), 'pagination' => ['pageSize' => -1]]);
echo GridView::widget(['dataProvider' => $dataProvider, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'order_id', 'description', 'order_date', 'shipment_date', 'tracking_id', 'delivery_date', 'arrived_in', ['attribute' => 'is_disputed', 'value' => function ($model) {
    $is_disputed_calc = $model->is_disputed == 1 ? 'Yes' : 'No';
    return "<b style='color:darkblue;'>" . $is_disputed_calc . "</b>";
}, 'format' => 'raw'], ['attribute' => 'status', 'value' => function ($model) {
    return "<b style='color:red;'>" . $model->status . "</b>";
}, 'format' => 'raw'], ['class' => 'yii\\grid\\ActionColumn', 'contentOptions' => ['style' => 'width:70px;'], 'header' => 'Actions', 'template' => '{view}', 'urlCreator' => function ($action, $model, $key, $index) {
    if ($action === 'view') {
        $url = '/package/view/' . $model->id;
        return $url;
    }
}]]]);
?>

    <h3>Items in transit</h3>
    <div style="background-color: #f1f1f1">
        <?php 
$trackingIDs = \app\models\Package::find()->innerJoin('courier', '`courier`.`id` = `package`.`courier_id`')->where(['courier.id' => $model->id, 'package.status' => 'Awaiting delivery'])->orderBy('id DESC')->all();
if ($trackingIDs != false) {
    foreach ($trackingIDs as $trackingID) {
        echo $trackingID->tracking_id . "<br />";
    }
}
?>
    </div>

</div>
 /**
  * Function to retrieve times available for a given date
  *
  * View is returned in JSON format
  *
  **/
 public function getTimes()
 {
     // We get the data from AJAX for the day selected, then we get all available times for that day
     $selectedDay = Input::get('selectedDay');
     $availableTimes = DB::table('booking_datetimes')->get();
     // We will now create an array of all booking datetimes that belong to the selected day
     // WE WILL NOT filter this in the query because we want to maintain compatibility with every database (ideally)
     // PSEUDO CODE
     // Get package duration of the chosen package
     $package = Package::find(Session::get('packageID'));
     $packageTime = $package->package_time;
     // For each available time...
     foreach ($availableTimes as $t => $value) {
         $startTime = new DateTime($value->booking_datetime);
         if ($startTime->format("Y-m-d") == $selectedDay) {
             $endTime = new DateTime($value->booking_datetime);
             date_add($endTime, date_interval_create_from_date_string($packageTime . ' hours'));
             // Try to grab any appointments between the start time and end time
             $result = Appointment::timeBetween($startTime->format("Y-m-d H:i"), $endTime->format("Y-m-d H:i"));
             // If no records are returned, the time is okay, if not, we must remove it from the array
             if ($result->first()) {
                 unset($availableTimes[$t]);
             }
         } else {
             unset($availableTimes[$t]);
         }
     }
     return response()->json($availableTimes);
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $package = Package::find($id);
     $package->delete();
     return redirect('/packages')->withMessage('<i class="glyphicon glyphicon-ok"></i> This package has been deleted');
 }
Ejemplo n.º 11
0
        if ($data->is_disputed != 1 && $data->shipment_date == "0000-00-00") {
            $details = "";
        } else {
            if ($data->is_disputed != 1 && $data->delivery_date != "0000-00-00" && $data->shipment_date != "0000-00-00") {
                $details = " - received on " . $data->delivery_date;
            } else {
                if ($data->is_disputed != 1 && $data->delivery_date == "0000-00-00" && $data->shipment_date != "0000-00-00") {
                    $details = " - en route since " . \app\models\Package::getDaysElapsed($data->shipment_date);
                } else {
                    $details = "";
                }
            }
        }
    }
    return "<b style='color:red;'>" . $data->status . "</b>" . $details;
}, 'filter' => Html::activeDropDownList($searchModel, 'status', ArrayHelper::map(\app\models\Package::find()->orderBy(['status' => SORT_ASC])->addGroupBy(['status'])->asArray()->all(), 'status', 'status'), ['class' => 'form-control', 'prompt' => 'Select...']), 'options' => array('width' => 160), 'format' => 'raw'], ['class' => 'yii\\grid\\ActionColumn', 'contentOptions' => ['style' => 'width:105px;'], 'template' => '{view} {shipped} {received} {update} {delete}', 'buttons' => ['shipped' => function ($url, $model) {
    if ($model->shipment_date == "0000-00-00") {
        $shippedButtonClass = "glyphicon-unchecked";
        $shippedButtonTitle = "Mark item as shipped?";
    } else {
        $shippedButtonClass = "glyphicon-check";
        $shippedButtonTitle = "Mistake? Mark item not shipped";
    }
    return Html::a('<span class="glyphicon ' . $shippedButtonClass . '"></span>', $url, ['title' => Yii::t('yii', $shippedButtonTitle), 'data-confirm' => Yii::t('yii', 'Are you sure you want to mark this item?'), 'data-method' => 'post', 'data-pjax' => '0']);
}, 'received' => function ($url, $model) {
    if ($model->delivery_date == "0000-00-00" && $model->shipment_date == "0000-00-00") {
        $receivedButtonClass = "glyphicon-ban-circle";
        $receivedButtonTitle = "Not yet shipped";
    } else {
        if ($model->delivery_date == "0000-00-00" && $model->shipment_date != "0000-00-00") {
            $receivedButtonClass = "glyphicon-heart-empty";