private function firstRun() { $suppliers = Supplier::all(); foreach ($suppliers as $supplier) { $new = Supplier::find($supplier->id); $new->id = Supplier::get_uid(); $new->save(); } }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Supplier::find(); $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(['id_supplier' => $this->id_supplier]); $query->andFilterWhere(['like', 'nama', $this->nama])->andFilterWhere(['like', 'no_telp', $this->no_telp])->andFilterWhere(['like', 'alamat', $this->alamat]); return $dataProvider; }
public function destroy($id) { $supplier = Supplier::find($id); if ($supplier) { $deleteProduct = Product::where('supplier_id', '=', $id)->delete(); if ($supplier->delete()) { return ['status' => 'success', 'message' => 'Supplier data successfully deleted.']; } else { return ['status' => 'failed', 'message' => 'Supplier data failed to deleted.']; } } else { return ['status' => 'failed', 'message' => 'Supplier data not found.']; } }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Supplier::find(); $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(['supplier_id' => $this->supplier_id, 'supplier_poscode' => $this->supplier_poscode]); $query->andFilterWhere(['like', 'supplier_name', $this->supplier_name])->andFilterWhere(['like', 'supplier_add1', $this->supplier_add1])->andFilterWhere(['like', 'supplier_add2', $this->supplier_add2])->andFilterWhere(['like', 'supplier_add3', $this->supplier_add3])->andFilterWhere(['like', 'supplier_tel', $this->supplier_tel])->andFilterWhere(['like', 'supplier_fax', $this->supplier_fax])->andFilterWhere(['like', 'supplier_email', $this->supplier_email])->andFilterWhere(['like', 'supplier_type', $this->supplier_type])->andFilterWhere(['like', 'supplier_remark', $this->supplier_remark])->andFilterWhere(['like', 'supplier_attention', $this->supplier_attention])->andFilterWhere(['like', 'supplier_active', $this->supplier_active])->andFilterWhere(['like', 'supplier_GSTno', $this->supplier_GSTno]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Supplier::find(); $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->joinWith(['country', 'province']); $query->andFilterWhere(['supplier_id' => $this->supplier_id, 'mi_supplier.flag_active' => 1]); $query->andFilterWhere(['like', 'supplier_name', $this->supplier_name])->andFilterWhere(['like', 'supplier_desc', $this->supplier_desc])->andFilterWhere(['like', 'contact_person', $this->contact_person])->andFilterWhere(['like', 'address_1', $this->address_1])->andFilterWhere(['like', 'address_2', $this->address_2])->andFilterWhere(['like', 'postcode', $this->postcode])->andFilterWhere(['like', 'city', $this->city])->andFilterWhere(['like', 'phone_1', $this->phone_1])->andFilterWhere(['like', 'phone_2', $this->phone_2])->andFilterWhere(['like', 'fax', $this->fax])->andFilterWhere(['like', 'country_name', $this->country_id])->andFilterWhere(['like', 'province_name', $this->province_id])->andFilterWhere(['like', 'logo_url', $this->logo_url]); return $dataProvider; }
public function index(Request $request) { $this->ch = curl_init(); curl_setopt($this->ch, CURLOPT_HEADER, true); curl_setopt($this->ch, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($this->ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($this->ch, CURLOPT_FOLLOWLOCATION, true); $this->supplier = Supplier::find($request->input('supplier_id')); if (method_exists($this, $this->supplier->shortname)) { $fn = $this->supplier->shortname; $result = $this->{$fn}($request->input('name'), $fn); } curl_close($this->ch); return json_encode($result); }
public function splitProductsBySupplier(array $carts) { $carts = collect($carts); $carts = $carts->map(function ($cart) { $product = Product::find($cart['product_id']); return ['product' => $product, 'quantity' => $cart['quantity']]; }); $grouping = $carts->groupBy(function ($cart) { return $cart['product']->supplier_id; }); $splits = array(); foreach ($grouping as $supplier_id => $carts) { $splits[] = ['supplier' => Supplier::find($supplier_id), 'carts' => $carts]; } return $splits; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Supplier::find()->active(); $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(['id' => $this->id]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'website', $this->website])->andFilterWhere(['like', 'address', $this->address])->andFilterWhere(['like', 'notes', $this->notes]); $query->with(['contacts']); if ($this->category_id != null) { $query->joinWith(['products' => function ($query) { $query->select('category_id'); $query->andWhere(['category_id' => $this->category_id]); }], true, 'INNER JOIN'); } return $dataProvider; }
/** * Update inventory item * GET /inventory/(item)/save * * @param Request $request * @param Inventory $item * * @return */ public function save(Request $request, Inventory $item) { $offset = count($request->category) - 1; /* * Set Category to NULL if requested category is 0 */ $category = $request->category[$offset]; if ($category == 0 && $offset < 1) { $category = NULL; } elseif ($category == 0) { $category = $request->category[$offset - 1]; } $item->serialnr = $request->serialnr; $item->name = $request->name; $item->brand_id = $request->brand_id; $item->category_id = $category; $item->save(); $item->saveDetails($request); $supplier = Supplier::find($request->supplier_id); return Picture::saveImages($item, $supplier, $request); //$item->updateBarcode($request->barcode); //return $item; }
/** * Show the form for editing the specified resource. * * @param int $id * @return Response */ public function edit($id, $is_price = null) { if (!is_null($is_price)) { $data = ['title' => 'Ubah Harga Material', 'asset' => new Assets(), 'position' => ['material' => 'Material', 'material/edit/' . $id . '/price' => 'Ubah Harga'], 'opened' => 'material', 'head' => Supp::find($id), 'fetch' => MatModel::forSupplierDetail($id)]; return view('material.editPrice', $data); } $role = $this->role; switch ($role) { case 1: //admin $accessable = ['', '', '', '', '', '', '', '', '', '', '']; break; case 2: //purchasing $accessable = ['', '', '', '', '', '', 'disabled="disabled"', 'disabled="disabled"', 'disabled="disabled"', 'disabled="disabled"', 'disabled="disabled"']; break; case 3: //rawmat $accessable = ['disabled="disabled"', 'disabled="disabled"', 'disabled="disabled"', 'disabled="disabled"', 'disabled="disabled"', 'disabled="disabled"', '', '', '', '', '']; break; case 4: //PPIC $accessable = ['disabled="disabled"', 'disabled="disabled"', 'disabled="disabled"', 'disabled="disabled"', 'disabled="disabled"', 'disabled="disabled"', '', '', '', '', '']; break; case 5: //Vice Director $accessable = ['', '', '', '', '', '', '', '', '', '', '']; break; } $data = ['title' => 'Ubah Data Material', 'asset' => new Assets(), 'position' => ['material' => 'Material', 'material/edit/' . $id => 'Ubah Data'], 'matauang' => MuModel::all(), 'warna' => Warna::orderBy('wrn_nama')->get(), 'mats' => Mats::orderBy('mats_nama')->get(), 'accessable' => $accessable, 'opened' => 'material', 'row' => MatModel::getEditData($id), 'role' => $role]; return view('material.edit', $data); }
public function actionSupplierlist() { $data = Supplier::find()->asArray()->all(); //print_r($data);exit; print json_encode($data); }
<?php use yii\helpers\Html; use yii\widgets\ActiveForm; use app\models\Category; use app\models\Supplier; use app\models\Product; use app\models\Currency; use yii\helpers\ArrayHelper; use zxbodya\yii2\galleryManager\GalleryManager; /* @var $this yii\web\View */ /* @var $model app\models\Product */ /* @var $form yii\widgets\ActiveForm */ $categories = Category::find()->active()->orderBy(['title' => SORT_ASC])->all(); $suppliers = Supplier::find()->active()->orderBy(['name' => SORT_ASC])->all(); $currencies = Currency::labels(); ?> <div class="product-form"> <?php $form = ActiveForm::begin(['enableClientValidation' => false, 'options' => ['enctype' => 'multipart/form-data']]); ?> <?php echo $form->field($model, 'category_id')->dropDownList(ArrayHelper::map($categories, 'id', 'title')); ?> <?php echo $form->field($model, 'supplier_id')->dropDownList(ArrayHelper::map($suppliers, 'id', 'name')); ?>
public static function getMainSuppliers() { $suppliers = Supplier::where('supplied_by', '>', 0)->get(); $main_supplier_ids = $suppliers->unique('supplied_by')->pluck('supplied_by')->toArray(); return Supplier::find($main_supplier_ids); }
public function get_supplier_code(Request $request) { if ($request->ajax()) { $supplier_id = $request->input('supplier_id'); $supplier_info = Supplier::find($supplier_id); return response()->json($supplier_info); } }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { if (Session::get('level') == '1' || Session::get('level') == '2' && Session::get('fingerprint') == md5($_SERVER['HTTP_USER_AGENT'] . $_SERVER['REMOTE_ADDR'])) { $Supplier = Supplier::find(e($id)); DB::transaction(function () use($Supplier) { Supplier::find($Supplier->id)->delete(); }); return Redirect::to('supplier'); } else { return Redirect::to('/'); } }
<?php use yii\helpers\Html; use yii\grid\GridView; use app\models\Category; use app\models\Supplier; use yii\helpers\ArrayHelper; use kartik\export\ExportMenu; /* @var $this yii\web\View */ /* @var $searchModel app\models\ProductSearch */ /* @var $dataProvider yii\data\ActiveDataProvider */ $this->title = 'Productos'; $this->params['breadcrumbs'][] = $this->title; $categories = Category::find()->all(); $suppliers = Supplier::find()->all(); ?> <div class="product-index"> <h1><?php echo Html::encode($this->title); ?> </h1> <?php // echo $this->render('_search', ['model' => $searchModel]); ?> <p> <?php echo Html::a('Crear producto', ['create'], ['class' => 'btn btn-success']); ?> <?php
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function delete($id) { //Soft delete the item $supplier = Supplier::find($id); if (count($supplier->stocks) > 0) { return redirect()->to('supplier.index')->with('message', trans('messages.failure-delete-record')); } else { $supplier->delete(); // redirect return redirect()->to('supplier.index')->with('message', trans('messages.record-successfully-deleted')); } }
/** * Returns a supplier by the specified ID. * * @param int|string $id * * @return mixed */ private function getSupplierById($id) { return Supplier::find($id); }
/** * Get the asset information to present to the supplier view page * * @param int $assetId * @return View **/ public function getView($supplierId = null) { $supplier = Supplier::find($supplierId); if (isset($supplier->id)) { return View::make('suppliers/view', compact('supplier')); } else { // Prepare the error message $error = trans('admin/suppliers/message.does_not_exist', compact('id')); // Redirect to the user management page return redirect()->route('suppliers')->with('error', $error); } }
public function delete(Request $request, $id) { $s = Supplier::find($id); $s->delete(); return Redirect('suppliers'); }
public static function supplier() { $listData = ArrayHelper::map(Supplier::find()->all(), 'id_supplier', 'nama'); return $listData; }
/** * print kb card small */ public function kbcardprint_small($id) { if (Session::get('level') != '' && Session::get('fingerprint') == md5($_SERVER['HTTP_USER_AGENT'] . $_SERVER['REMOTE_ADDR'])) { $data = KbCard::find($id); $data_sp = Supplier::find($data->supplier_id); //----------- create card --------------// $pagelayout = array(75, 188); // or array($height, $width) $pdf = new TCPDF('p', 'mm', $pagelayout, true, 'UTF-8', false); //$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); $pdf->SetPrintHeader(false); $pdf->SetPrintFooter(false); $pdf->SetHeaderData('', '', '', ''); // set default monospaced font $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); // set margins $pdf->SetMargins(0, 0, 0); $pdf->SetDisplayMode('fullpage', 'SinglePage', 'UseNone'); $pdf->AddPage('P'); $pdf->SetFont('freeserif', 'B', 12, '', true); $pdf->SetXY(1, 1); $pdf->MultiCell(75, 0, 'แผนก : ' . $this->getsp_dep($data->id_dep), 0, 'L', 0, 1, '', '', true); $pdf->SetFont('freeserif', '', 12, '', true); $pdf->SetXY(1, 8); $pdf->MultiCell(75, 0, 'เลขที่ : ' . $data['supplier_code'], 0, 'L', 0, 1, '', '', true); $pdf->SetFont('freeserif', 'B', 12, '', true); $pdf->SetXY(1, 12); $pdf->MultiCell(75, 0, 'รายการ : ' . $this->getsp_name($data->supplier_id), 0, 'L', 0, 1, '', '', true); $pdf->SetFont('freeserif', '', 12, '', true); $pdf->SetXY(1, 22); $pdf->MultiCell(75, 0, 'จำนวนมากสุด : ' . $data->max_unit . ' จำนวนน้อยสุด : ' . $data->min_unit, 0, 'L', 0, 1, '', '', true); $pdf->SetFont('freeserif', 'B', 13, '', true); $pdf->SetXY(1, 27); $pdf->MultiCell(75, 0, 'จำนวนที่เบิก : ' . ($data->max_unit - $data->min_unit), 0, 'L', 0, 1, '', '', true); $style = array('border' => 2, 'vpadding' => 'auto', 'hpadding' => 'auto', 'fgcolor' => array(0, 0, 0), 'bgcolor' => false, 'module_width' => 1, 'module_height' => 1); $pdf->SetFont('freeserif', '', 11, '', true); $pdf->SetXY(1, 25); $pdf->write2DBarcode($data->id_dep . '|' . $data->max_unit . '|' . $data->min_unit . '|' . $data->supplier_id . '|' . $data->supplier_code . '|' . $data_sp->sp_name, 'QRCODE,Q', 1, 35, 38, 32, $style, 'N'); $filename = storage_path() . '/report/kumbukcard_small.pdf'; $contents = $pdf->output($filename, 'D'); } else { return Redirect::to('/'); } }