当前位置: 首页>>代码示例>>PHP>>正文


PHP Items::save方法代码示例

本文整理汇总了PHP中Items::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Items::save方法的具体用法?PHP Items::save怎么用?PHP Items::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Items的用法示例。


在下文中一共展示了Items::save方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: updateItem

function updateItem($line_of_text)
{
    $model = new Items();
    $model->item_id = $line_of_text[0];
    $model->company_id = $line_of_text[1];
    $model->part_number = $line_of_text[2];
    if (empty($model->part_number)) {
        $model->part_number = 'Not Available';
    }
    $model->name = $line_of_text[3];
    if (empty($model->name)) {
        $model->name = 'Not Available';
    }
    $model->description = $line_of_text[4];
    $model->barcode = $line_of_text[5];
    $model->location_room = $line_of_text[6];
    $model->location_row = $line_of_text[7];
    $model->location_column = $line_of_text[8];
    $model->location_shelf = $line_of_text[9];
    $model->category_id = $line_of_text[10];
    $model->current_quantity = $line_of_text[11];
    if (empty($model->current_quantity)) {
        $model->current_quantity = '0';
    }
    $model->available_quantity = $line_of_text[12];
    if (empty($model->available_quantity)) {
        $model->available_quantity = '0';
    }
    $model->recommended_lowest_quantity = $line_of_text[13];
    $model->recommended_highest_quantity = $line_of_text[14];
    $model->remarks = $line_of_text[15];
    $model->active = $line_of_text[16];
    $model->image_url = $line_of_text[17];
    $model->sale_price = $line_of_text[18];
    $model->factory_due_date = $line_of_text[19];
    $model->suppliers_id = $line_of_text[20];
    $model->fits_in_model = $line_of_text[21];
    $model->created = $line_of_text[22];
    $model->modified = $line_of_text[23];
    $model->deleted = $line_of_text[24];
    if ($model->save()) {
        echo '<tr style="background-color:#EAF2D3"><td>' . $model->part_number . '</td><td>Part Number Saved</td><td></td> </tr>';
    } else {
        $errors = $model->getErrors();
        echo '<tr style="background-color:#FF8566"><td>' . $model->part_number . '</td><td>Part Number Not Saved</td><td>';
        echo "Item not imported";
        foreach ($errors as $e) {
            echo "<br>" . $e[0];
        }
        echo '</td></tr>';
        //print_r($model->getErrors()).'</td></tr>';
    }
    //end of save else
}
开发者ID:EmmanuelFernando,项目名称:rapport-stock-control,代码行数:54,代码来源:csvuploadandimport.php

示例2: actionCreate

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Items();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Items'])) {
         $model->attributes = $_POST['Items'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->item_id));
         }
     }
     $this->render('create', array('model' => $model));
 }
开发者ID:EmmanuelFernando,项目名称:rapport-stock-control,代码行数:17,代码来源:ItemsController.php

示例3: actionCreate

 public function actionCreate()
 {
     Yii::app()->clientScript->registerPackage('items-edit');
     if (!isset($_GET['id']) || NULL == ($model = Items::model()->findByAttributes(array('user_id' => Yii::app()->user->id, 'id' => (int) $_GET['id'])))) {
         $model = new Items();
     }
     if (isset($_POST['Items'])) {
         $model->attributes = $_POST['Items'];
         $fn = Files::model()->uploadFile('Items[image]');
         if ($fn) {
             $model->image = $fn['filename'];
         } elseif (isset($_POST['Items']['image_src'])) {
             $model->image = $_POST['Items']['image_src'];
         }
         $new = $model->isNewRecord;
         if ($model->save()) {
             $cats = isset($_POST['categories']) ? $_POST['categories'] : array();
             if (!$new && empty($cats)) {
                 ItemsCategory::model()->deleteAllByAttributes(array('item_id' => $model->id));
             } else {
                 if (!$new) {
                     $dbcats = ItemsCategory::model()->findAll('item_id=:iid', array('iid' => $model->id));
                     $ids = array();
                     foreach ($dbcats as $i => $dbc) {
                         if (false !== ($k = array_search($dbc->category_id, $cats))) {
                             unset($cats[$k]);
                             unset($dbc[$i]);
                         } else {
                             $ids[] = $dbc->category_id;
                         }
                     }
                     //deleteing corresponding categories
                     if (!empty($ids)) {
                         $ids = implode(",", $ids);
                         ItemsCategory::model()->deleteAll('item_id=:iid AND category_id IN (:cid)', array('iid' => $model->id, 'cid' => $ids));
                     }
                 }
                 if (!empty($cats)) {
                     foreach ($cats as $cat) {
                         $c = new ItemsCategory();
                         $c->attributes = array('category_id' => $cat, 'item_id' => $model->id);
                         $c->save();
                     }
                 }
             }
             Yii::app()->user->setFlash('ItemSaved', '1');
             $this->refresh();
         }
     }
     $this->render('_form', array('model' => $model));
 }
开发者ID:BGCX067,项目名称:facecom-svn-to-git,代码行数:51,代码来源:ItemsController.php

示例4: actionCreate

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Items();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Items'])) {
         $model->attributes = $_POST['Items'];
         if (!empty($_FILES['Items']['name']['itm_photo'])) {
             $image_name = $this->imageUpload($_FILES['Items']['name']['itm_photo'], $_FILES['Items']['tmp_name']['itm_photo'], 'products');
         }
         if (!empty($image_name)) {
             $model->itm_photo = $image_name;
         } else {
             unset($model->itm_photo);
         }
         if ($model->save()) {
             $this->redirect(array('index'));
         }
     }
     $this->render('create', array('model' => $model));
 }
开发者ID:jayant06,项目名称:lukurug,代码行数:25,代码来源:ItemsController.php

示例5: postNew

 public function postNew()
 {
     // Get input values
     $task = Input::get('new');
     $dater = Input::get('date');
     $hour = Input::get('hour');
     $minute = Input::get('minutes');
     $date = $dater . ' ' . $hour . ':' . $minute . ':00';
     $date = strtotime($date);
     $date = Date("Y-m-d H:i:s", $date);
     // Validation
     $rules = array('new' => 'required|min:5|max:255');
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         return Redirect::route('home')->withErrors($validator);
     }
     //Add new task
     $items = new Items();
     $items->name = $task;
     $items->dueDate = $date;
     $items->save();
     return Redirect::route('home');
 }
开发者ID:kruzerdesigns,项目名称:ToDo,代码行数:23,代码来源:HomeController.php

示例6: createOrder

 public function createOrder()
 {
     $order_create = new Logger('OrderCreation');
     $response = array();
     $output = array();
     try {
         $order = new Orders();
         if (!Input::has('user_id') || !Input::has('items')) {
             /*
              * There shd be a single class which handles all this.
              */
             $response['response_code'] = ResponseCodes::$response_code['missing_param']['code'];
             $response['response_message'] = ResponseCodes::$response_code['missing_param']['response_message'];
             echo json_encode($response);
             die;
         }
         // Save the order to the database
         $order->status = AppConstants::$avialable_status['created'];
         //  the user id is assumed to be a part of the request.
         //  Ideally it shouldn't be.The server shd be able to identify the user based on session id or token or any other method
         $order->user_id = Input::get('user_id');
         $order->save();
         /*
          * While saving items we assume that we are getting a json encoded data for the list of item. 
          * like this [{"name":"shirt","quantity":"2"},{"name":"saree","quantity":"2"}]
          * with the product name and the quanity.Each item added belongs to a specific type which has a fixed price whc are intrenally mapped 
          */
         $list_of_items = json_decode(Input::get('items'), true);
         foreach ($list_of_items as $key => $item_data) {
             $item = new Items();
             $item->order_id = $order->id;
             $item->name = $item_data['name'];
             $item->quantity = $item_data['quantity'];
             // assuming the item type is correct.
             $item->price = Price::$price_mapping[$item_data['name']] * $item_data['quantity'];
             $item->save();
         }
         $output['order_id'] = $order->id;
         $response['response_code'] = ResponseCodes::$response_code['success']['code'];
         $response['response_message'] = ResponseCodes::$response_code['success']['response_message'];
         $response['output'] = $output;
         echo json_encode($response);
     } catch (Exception $e) {
         Log::error($e->getMessage());
         $order_create->addInfo($e->getMessage());
         $response['response_code'] = ResponseCodes::$response_code['internal_server_error']['code'];
         $response['response_message'] = ResponseCodes::$response_code['internal_server_error']['response_message'];
         $response['output'] = $output;
         echo json_encode($response);
     }
 }
开发者ID:anil477,项目名称:Fab,代码行数:51,代码来源:OrdersController.php

示例7: postNewItem

 public function postNewItem()
 {
     $input = Input::all();
     $rules = array('cat' => 'required', 'item_precio_dol' => 'required', 'item_cod' => 'required|unique:item', 'item_nomb' => 'required|min:4', 'item_desc' => 'required|min:4');
     $msg = array('required' => 'El campo :attribute es obligatorio', 'min' => 'El campo :attribute es muy corto(a)', 'unique' => 'El campo :attribute debe ser unico');
     $attr = array('cat' => 'categoría', 'item_precio' => 'precio', 'item_precio_dol' => 'precio en dolares', 'item_cod' => 'artículo', 'item_nomb' => 'artículo', 'item_desc' => 'artículo');
     $validation = Validator::make($input, $rules, $msg, $attr);
     if ($validation->fails()) {
         return Redirect::to('administrador/nuevo-articulo')->withErrors($validation)->withInput();
     } else {
         $item = new Items();
         $item->item_cat = $input['cat'];
         if (!empty($input['subcat'])) {
             $item->item_subcat = $input['subcat'];
         }
         $item->item_cod = $input['item_cod'];
         $item->item_nomb = $input['item_nomb'];
         $item->item_desc = $input['item_desc'];
         $item->item_precio = $input['item_precio_dol'];
         $item->save();
         $id = $item->id;
         $misc = new Misc();
         $misc->item_id = $id;
         $misc->save();
         $misc_id = $misc->id;
         if (!file_exists('images/items/' . $id)) {
             mkdir('images/items/' . $id);
         }
         return Redirect::to('administrador/nuevo-articulo/continuar/' . $id . '/' . $misc_id);
     }
 }
开发者ID:bakuryuthem0,项目名称:nia,代码行数:31,代码来源:AdminController.php


注:本文中的Items::save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。