本文整理汇总了PHP中Supplier::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Supplier::save方法的具体用法?PHP Supplier::save怎么用?PHP Supplier::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Supplier
的用法示例。
在下文中一共展示了Supplier::save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: StockCreationExample
public function StockCreationExample()
{
$metric = new Metric();
$metric->name = 'Unit';
$metric->symbol = 'U';
$metric->save();
//Now, create a category to store the inventory record under:
$category = new Category();
$category->name = 'VoIP';
$category->save();
$item = new Inventory();
$item->metric_id = $metric->id;
$item->category_id = $category->id;
$item->name = 'SNOM Headset';
$item->description = 'Very nice for the ear';
$item->save();
$location = new Location();
$location->name = 'Snowball Small Stock Room';
$location->save();
$item->createStockOnLocation(2, $location);
$item->createSku('PART1234');
dd($item->sku_code);
//$res = Inventory::findBySku(Input::get('sku'));
//$item = Inventory::find(1);
//dd($item);
$supplier = new Supplier();
//Mandatory fields
$supplier->name = 'Miro Distribution';
//Optional fields
$supplier->address = 'Montague Gardens';
$supplier->postal_code = '8000';
$supplier->zip_code = '12345';
$supplier->country = 'South Africa';
$supplier->region = 'Western Cape';
$supplier->city = 'Cape Town';
$supplier->contact_title = 'Sales Rep';
$supplier->contact_name = 'Mark Sparky';
$supplier->contact_phone = '555 555-5555';
$supplier->contact_fax = '555 555-5556';
$supplier->contact_email = 'mark@miro.co.za';
$supplier->save();
$item = Inventory::find(1);
//$supplier = Supplier::find(1);
$item->addSupplier($supplier);
}
示例2: post
public function post()
{
$post = Input::all();
$validator = Supplier::validate($post);
$supplierId = $post['id'];
if ($validator->fails()) {
return Redirect::to('distribuidores/' . $supplierId)->withErrors($validator)->withInput();
} else {
$supplier = self::__checkExistence($supplierId);
if (!$supplierId) {
$supplier = new Supplier();
}
$supplier->name = $post['name'];
$supplier->ruc = $post['ruc'];
$supplier->address = $post['address'];
$supplier->phone = $post['phone'];
$supplier->email = $post['email'];
$supplier->web = $post['web'];
$supplier->contact = $post['contact'];
$supplier->contact_phone = $post['contact_phone'];
$supplier->save();
if ($post['status'] == 'inactive') {
$supplier->delete();
} else {
if ($supplier->trashed()) {
$supplier->restore();
}
}
Session::flash('success', 'Distribuidor guardado correctamente.');
return Redirect::to('distribuidores');
}
}
示例3: store
/**
* Store a newly created resource in storage.
* POST /supplier
*
* @return Response
*/
public function store()
{
$validator = Validator::make(Input::all(), Supplier::$rules);
if ($validator->fails()) {
return Redirect::to('supplier')->withErrors($validator)->withInput(Input::all());
} else {
if (Supplier::where('id_supp', '=', Input::get('id_supp'))->exists()) {
$supplier = Supplier::find(Input::get('id_supp'));
$supplier->nm_supp = Input::get('nm_supp');
$supplier->alamat = Input::get('alamat');
$supplier->telp = Input::get('telp');
$supplier->fax = Input::get('fax');
$supplier->save();
Session::flash('message', 'Successfully updated supplier!');
return Redirect::to('supplier');
} else {
$supplier = new Supplier();
$supplier->id_supp = Input::get('id_supp');
$supplier->nm_supp = Input::get('nm_supp');
$supplier->alamat = Input::get('alamat');
$supplier->telp = Input::get('telp');
$supplier->fax = Input::get('fax');
$supplier->save();
Session::flash('message', 'Successfully created supplier!');
return Redirect::to('supplier');
}
}
}
示例4: createSupplier
public function createSupplier()
{
$rule = array('first_name' => 'required', 'email' => 'email|required');
$cust = Input::all();
$valid = Validator::make($cust, $rule);
if ($valid->fails()) {
return Redirect::to('add-supplier');
} else {
$supplier = new Supplier();
$supplier->company_name = Input::get('company_name');
$supplier->first_name = Input::get('first_name');
$supplier->last_name = Input::get('last_name');
$supplier->email = Input::get('email');
$supplier->phone_number = Input::get('phone_number');
$supplier->address_1 = Input::get('address_1');
$supplier->address_2 = Input::get('address_2');
$supplier->city = Input::get('city');
$supplier->state = Input::get('state');
$supplier->zip = Input::get('zip');
$supplier->country = Input::get('country');
$supplier->comment = Input::get('comment');
$supplier->account = Input::get('account');
$supplier->save();
return Redirect::to('all-suppliers');
}
}
示例5: Create
public static function Create($name, $person, $telephone, $email, $address, $bal)
{
$type = new PartyType('Supplier');
$supplier = new Supplier($type, $name, $person, $telephone, $email, $address, $bal);
if ($supplier->save()) {
return $supplier;
}
return false;
}
示例6: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
$model = new Supplier();
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if (isset($_POST['Supplier'])) {
$model->attributes = $_POST['Supplier'];
if ($model->save()) {
$this->redirect(['admin']);
}
}
$this->render('create', ['model' => $model]);
}
示例7: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
$model = new Supplier();
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if (isset($_POST['Supplier'])) {
$model->attributes = $_POST['Supplier'];
if ($model->save()) {
Yii::app()->user->setFlash('info', MyFormatter::alertInfo('<strong>Selamat!</strong> Data telah berhasil disimpan.'));
$this->redirect(array('view', 'id' => $model->ID_SUPPLIER));
}
}
$this->render('create', array('model' => $model));
}
示例8: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate($recv_mode = 'N', $trans_mode = null)
{
$model = new Supplier();
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if (Yii::app()->user->checkAccess('supplier.create')) {
if (isset($_POST['Supplier'])) {
$model->attributes = $_POST['Supplier'];
if ($model->validate()) {
$transaction = Yii::app()->db->beginTransaction();
try {
if ($model->save()) {
AccountSupplier::model()->saveAccount($model->id, $model->company_name);
$transaction->commit();
if ($recv_mode == 'N') {
Yii::app()->user->setFlash(TbHtml::ALERT_COLOR_SUCCESS, 'Supplier : <strong>' . $model->company_name . '</strong> have been saved successfully!');
$this->redirect(array('create'));
} else {
Yii::app()->receivingCart->setSupplier($model->id);
$this->redirect(array('receivingItem/index', 'trans_mode' => $trans_mode));
}
/*
Yii::app()->clientScript->scriptMap['jquery.js'] = false;
echo CJSON::encode(array(
'status'=>'success',
'div'=>"<div class=alert alert-info fade in>Successfully added ! </div>",
));
Yii::app()->end();
*
*/
}
} catch (CDbException $e) {
$transaction->rollback();
Yii::app()->user->setFlash(TbHtml::ALERT_COLOR_WARNING, 'Oop something wrong : <strong>' . $e->getMessage());
}
}
}
} else {
throw new CHttpException(403, 'You are not authorized to perform this action');
}
if (Yii::app()->request->isAjaxRequest) {
Yii::app()->clientScript->scriptMap['*.js'] = false;
echo CJSON::encode(array('status' => 'render', 'div' => $this->renderPartial('_form', array('model' => $model), true, false)));
Yii::app()->end();
} else {
$this->render('create', array('model' => $model));
}
}
示例9: doSave
/**
* Performs the work of inserting or updating the row in the database.
*
* If the object is new, it inserts it; otherwise an update is performed.
* All related objects are also updated in this method.
*
* @param PropelPDO $con
* @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
* @throws PropelException
* @see save()
*/
protected function doSave(PropelPDO $con)
{
$affectedRows = 0;
// initialize var to track total num of affected rows
if (!$this->alreadyInSave) {
$this->alreadyInSave = true;
// We call the save method on the following object(s) if they
// were passed to this object by their corresponding set
// method. This object relates to these object(s) by a
// foreign key reference.
if ($this->aSupplier !== null) {
if ($this->aSupplier->isModified() || $this->aSupplier->isNew()) {
$affectedRows += $this->aSupplier->save($con);
}
$this->setSupplier($this->aSupplier);
}
if ($this->isNew() || $this->isModified()) {
// persist changes
if ($this->isNew()) {
$this->doInsert($con);
} else {
$this->doUpdate($con);
}
$affectedRows += 1;
$this->resetModified();
}
if ($this->detailBarangMasuksScheduledForDeletion !== null) {
if (!$this->detailBarangMasuksScheduledForDeletion->isEmpty()) {
DetailBarangMasukQuery::create()->filterByPrimaryKeys($this->detailBarangMasuksScheduledForDeletion->getPrimaryKeys(false))->delete($con);
$this->detailBarangMasuksScheduledForDeletion = null;
}
}
if ($this->collDetailBarangMasuks !== null) {
foreach ($this->collDetailBarangMasuks as $referrerFK) {
if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
$affectedRows += $referrerFK->save($con);
}
}
}
$this->alreadyInSave = false;
}
return $affectedRows;
}
示例10: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store()
{
//
$rules = array('name' => 'required|unique:suppliers,name');
$validator = Validator::make(Input::all(), $rules);
if ($validator->fails()) {
return Redirect::back()->withErrors($validator);
} else {
// store
$supplier = new Supplier();
$supplier->name = Input::get('name');
$supplier->phone_no = Input::get('phone_no');
$supplier->email = Input::get('email');
$supplier->physical_address = Input::get('physical_address');
try {
$supplier->save();
return Redirect::route('supplier.index')->with('message', 'Successifully added a new supplier');
} catch (QueryException $e) {
Log::error($e);
}
}
}
示例11: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store()
{
$rules = array('name' => 'required|unique:suppliers,name');
$validator = Validator::make(Input::all(), $rules);
if ($validator->fails()) {
return Redirect::back()->withErrors($validator)->WithInput();
} else {
// store
$supplier = new Supplier();
$supplier->name = Input::get('name');
$supplier->phone = Input::get('phone');
$supplier->email = Input::get('email');
$supplier->address = Input::get('address');
$supplier->user_id = Auth::user()->id;
try {
$supplier->save();
$url = Session::get('SOURCE_URL');
return Redirect::to($url)->with('message', trans('messages.record-successfully-saved'));
} catch (QueryException $e) {
Log::error($e);
}
}
}
示例12: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store()
{
//
$rules = array("supplierId" => "required", "supplierName" => "required", "firstAddress" => "required", "secondAddress" => "required", "area" => "required", "region" => "required", "supplierPhone" => "required|numeric", "supplierFax" => "required|numeric", "supplierEmail" => "required|email", "supplierContact" => "required", "supplierMobile" => "required|numeric");
$validator = Validator::make(Input::all(), $rules);
if ($validator->fails()) {
return Redirect::to('/supplier/create')->withErrors($validator);
}
//
$supplier = new Supplier();
$supplier->supplierID = Input::get('supplierId');
$supplier->supplierName = Input::get('supplierName');
$supplier->supplierAddress1 = Input::get('firstAddress');
$supplier->supplierAddress2 = Input::get('secondAddress');
$supplier->areaID = Input::get("area");
$supplier->regionID = Input::get("region");
$supplier->supplierPhone = Input::get("supplierPhone");
$supplier->supplierFax = Input::get("supplierFax");
$supplier->supplierEmail = Input::get("supplierEmail");
$supplier->supplierContact = Input::get("supplierContact");
$supplier->supplierMobile = Input::get("supplierMobile");
$supplier->save();
return Redirect::to('/supplier');
}
示例13: getVendor
/**
* To get Vendor from client's Data
*/
function getVendor()
{
$this->autoRender = false;
$sql = "SELECT * FROM vendors;";
$datas = $this->Cabinet->query($sql);
App::uses("Supplier", "Inventory.Model");
foreach ($datas as $data) {
$supplier = new Supplier();
$vendor['Supplier']['name'] = $data['vendors']['Name'];
$vendor['Supplier']['address'] = $data['vendors']['AddressLine1'];
$vendor['Supplier']['city'] = $data['vendors']['City'];
$vendor['Supplier']['postal_code'] = $data['vendors']['Postal'];
$vendor['Supplier']['province'] = $data['vendors']['Province'];
$vendor['Supplier']['country'] = "Canada";
$vendor['Supplier']['phone'] = $data['vendors']['PhoneNumber'];
$vendor['Supplier']['fax_number'] = $data['vendors']['FaxNumber'];
$vendor['Supplier']['terms'] = $data['vendors']['Terms'];
$vendor['Supplier']['notes'] = $data['vendors']['Notes'];
$vendor['Supplier']['email'] = $data['vendors']['EmailAddress'];
$vendor['Supplier']['qb_suplier_name'] = $data['vendors']['QBAccountName'];
$vendor['Supplier']['door_supplier'] = $data['vendors']['DoorVendor'];
$vendor['Supplier']['cabinet_supplier'] = $data['vendors']['BoxVendor'];
$vendor['Supplier']['laminate_supplier'] = $data['vendors']['LaminateVendor'];
$vendor['Supplier']['hardware_supplier'] = $data['vendors']['HardwareVendor'];
$vendor['Supplier']['gst_rate'] = $data['vendors']['GST'];
$vendor['Supplier']['pst_rate'] = $data['vendors']['PST'];
$vendor['Supplier']['notes_on_po'] = $data['vendors']['POMemo'];
if (!$supplier->save($vendor)) {
pr($supplier->validationErrors);
}
}
}
示例14: fire
//.........这里部分代码省略.........
}
$user_username = $email_prefix;
// Generate an email based on their name if no email address is given
if ($user_email == '') {
if ($first_name == 'Unknown') {
$status_id = 7;
}
$email = strtolower($email_prefix) . '@' . $this->option('domain');
$user_email = str_replace("'", '', $email);
}
}
$this->comment('Full Name: ' . $user_name);
$this->comment('First Name: ' . $first_name);
$this->comment('Last Name: ' . $last_name);
$this->comment('Username: ' . $user_username);
$this->comment('Email: ' . $user_email);
$this->comment('License Name: ' . $user_license_name);
$this->comment('Serial No: ' . $user_license_serial);
$this->comment('Licensed To Name: ' . $user_licensed_to_name);
$this->comment('Licensed To Email: ' . $user_licensed_to_email);
$this->comment('Seats: ' . $user_license_seats);
$this->comment('Reassignable: ' . $user_license_reassignable);
$this->comment('Supplier: ' . $user_license_supplier);
$this->comment('Maintained: ' . $user_license_maintained);
$this->comment('Notes: ' . $user_license_notes);
$this->comment('Purchase Date: ' . $user_license_purchase_date);
$this->comment('------------- Action Summary ----------------');
if ($user_username != '') {
if ($user = User::where('username', $user_username)->whereNotNull('username')->first()) {
$this->comment('User ' . $user_username . ' already exists');
} else {
// Create the user
$user = Sentry::createUser(array('first_name' => $first_name, 'last_name' => $last_name, 'email' => $user_email, 'username' => $user_username, 'password' => substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, 10), 'activated' => true, 'permissions' => array('admin' => 0, 'user' => 1), 'notes' => 'User importerd through license importer'));
// Find the group using the group id
$userGroup = Sentry::findGroupById(3);
// Assign the group to the user
$user->addGroup($userGroup);
$this->comment('User ' . $first_name . ' created');
}
} else {
$user = new User();
$user->user_id = NULL;
}
// Check for the supplier match and create it if it doesn't exist
if ($supplier = Supplier::where('name', $user_license_supplier)->first()) {
$this->comment('Supplier ' . $user_license_supplier . ' already exists');
} else {
$supplier = new Supplier();
$supplier->name = e($user_license_supplier);
$supplier->user_id = 1;
if ($supplier->save()) {
$this->comment('Supplier ' . $user_license_supplier . ' was created');
} else {
$this->comment('Something went wrong! Supplier ' . $user_license_supplier . ' was NOT created');
}
}
// Add the license
$license = new License();
$license->name = e($user_license_name);
if ($user_license_purchase_date != '') {
$license->purchase_date = $user_license_purchase_date;
} else {
$license->purchase_date = NULL;
}
$license->serial = e($user_license_serial);
$license->seats = e($user_license_seats);
$license->supplier_id = $supplier->id;
$license->user_id = 1;
if ($user_license_purchase_date != '') {
$license->purchase_date = $user_license_purchase_date;
} else {
$license->purchase_date = NULL;
}
$license->license_name = $user_licensed_to_name;
$license->license_email = $user_licensed_to_email;
$license->notes = e($user_license_notes);
if ($license->save()) {
$this->comment('License ' . $user_license_name . ' with serial number ' . $user_license_serial . ' was created');
$license_seat_created = 0;
for ($x = 0; $x < $user_license_seats; $x++) {
// Create the license seat entries
$license_seat = new LicenseSeat();
$license_seat->license_id = $license->id;
$license_seat->assigned_to = $user->id;
if ($license_seat->save()) {
$license_seat_created++;
}
}
if ($license_seat_created > 0) {
$this->comment($license_seat_created . ' seats were created');
} else {
$this->comment('Something went wrong! NO seats for ' . $user_license_name . ' were created');
}
} else {
$this->comment('Something went wrong! License ' . $user_license_name . ' was NOT created');
}
$this->comment('=====================================');
return true;
});
}
示例15: actionUpload
public function actionUpload()
{
parent::actionUpload();
$folder = $_SERVER['DOCUMENT_ROOT'] . Yii::app()->request->baseUrl . '/upload/';
// folder for uploaded files
$allowedExtensions = array("csv");
$sizeLimit = (int) Yii::app()->params['sizeLimit'];
// maximum file size in bytes
$uploader = new qqFileUploader($allowedExtensions, $sizeLimit);
$result = $uploader->handleUpload($folder, true);
$row = 0;
if (($handle = fopen($folder . $uploader->file->getName(), "r")) !== FALSE) {
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
if ($row > 0) {
$model = Supplier::model()->findByPk((int) $data[0]);
if ($model === null) {
$model = new Supplier();
}
$model->addressbookid = (int) $data[0];
$model->fullname = $data[1];
$model->recordstatus = (int) $data[2];
try {
if (!$model->save()) {
$errormessage = $model->getErrors();
if (Yii::app()->request->isAjaxRequest) {
echo CJSON::encode(array('status' => 'failure', 'div' => $errormessage));
}
}
} catch (Exception $e) {
$errormessage = $e->getMessage();
if (Yii::app()->request->isAjaxRequest) {
echo CJSON::encode(array('status' => 'failure', 'div' => $errormessage));
}
}
}
$row++;
}
fclose($handle);
}
$result = htmlspecialchars(json_encode($result), ENT_NOQUOTES);
echo $result;
}