本文整理汇总了PHP中Customers::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Customers::save方法的具体用法?PHP Customers::save怎么用?PHP Customers::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Customers
的用法示例。
在下文中一共展示了Customers::save方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store()
{
$validator = Validator::make(Input::all(), Sales::$rules);
if ($validator->passes()) {
// Create customer if required
$customer = new Customers();
if (Input::get('name')) {
$customer->name = Input::get('name');
$customer->address = Input::get('address');
$customer->contact = Input::get('contact');
$customer->save();
}
$sale = new Sales();
$sale->reference_no = '';
$sale->customer_id = $customer->id ? $customer->id : 0;
$sale->outlet_id = $this->user->outlet_id;
$sale->discount = Input::get('discount');
$sale->paid = Input::get('paid');
$sale->total = Input::get('grandtotal');
$sale->notes = Input::get('notes');
$sale->status = Input::get('paid') == Input::get('grandtotal') ? 'completed' : 'credit';
if ($sale->save()) {
$sale->reference_no = 'SALE-' . date('Ymd') . '-' . str_pad($sale->id, 3, 0, STR_PAD_LEFT);
$sale->save();
foreach (Input::get('cart') as $productId => $item) {
$itemDiscount = 0;
if ($item['discount_type'] == 'fixed') {
$itemDiscount = $item['discount_amount'] * $item['quantity'];
} elseif ($item['discount_type'] == 'percentage') {
$itemDiscount = $item['discount_amount'] / 100 * $item['sp'] * $item['quantity'];
}
$salesItem = new SalesItems();
$salesItem->sales_id = $sale->id;
$salesItem->product_id = $productId;
$salesItem->cp = $item['cp'];
$salesItem->sp = $item['sp'];
$salesItem->quantity = $item['quantity'];
$salesItem->total = $item['quantity'] * $item['sp'] - $itemDiscount;
$salesItem->discount_type = $item['discount_type'];
$salesItem->discount_amount = $item['discount_amount'];
$salesItem->discount_total = $itemDiscount;
$salesItem->save();
if ($this->user->outlet_id != 0) {
$outletstock = OutletsStocks::where('product_id', '=', $productId)->where('outlet_id', '=', $this->user->outlet_id)->first();
$outletstock->quantity = $outletstock->quantity - $salesItem->quantity;
$outletstock->save();
} else {
// Update product stock
$product = Products::find($productId);
$product->quantity = $product->quantity - $salesItem->quantity;
$product->save();
}
}
}
return Redirect::route('sales.edit', $sale->id)->with('success', 'New sale added successfully');
} else {
return Redirect::route('sales.create')->withErrors($validator)->withInput(Input::all());
}
}
示例2: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
$model = new Customers();
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if (isset($_POST['Customers'])) {
$model->attributes = $_POST['Customers'];
if ($model->save()) {
//sleep(2);
$this->redirect($this->createAbsoluteUrl('index'), array('customerName' => $model->customerName, 'sts' => 'created'));
}
}
$this->render('create', array('model' => $model));
}
示例3: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store()
{
$validator = Validator::make(Input::all(), Customers::$rules);
if ($validator->passes()) {
$customer = new Customers();
$customer->name = Input::get('name');
$customer->address = Input::get('address');
$customer->contact = Input::get('contact');
$customer->save();
return Redirect::route('customers.index')->with('success', 'Customer created successfully');
} else {
return Redirect::route('customers.create')->withErrors($validator)->withInput(Input::all());
}
}
示例4: 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->aCustomers !== null) {
if ($this->aCustomers->isModified() || $this->aCustomers->isNew()) {
$affectedRows += $this->aCustomers->save($con);
}
$this->setCustomers($this->aCustomers);
}
if ($this->isNew() || $this->isModified()) {
// persist changes
if ($this->isNew()) {
$this->doInsert($con);
} else {
$this->doUpdate($con);
}
$affectedRows += 1;
$this->resetModified();
}
if ($this->detailTransaksisScheduledForDeletion !== null) {
if (!$this->detailTransaksisScheduledForDeletion->isEmpty()) {
DetailTransaksiQuery::create()->filterByPrimaryKeys($this->detailTransaksisScheduledForDeletion->getPrimaryKeys(false))->delete($con);
$this->detailTransaksisScheduledForDeletion = null;
}
}
if ($this->collDetailTransaksis !== null) {
foreach ($this->collDetailTransaksis as $referrerFK) {
if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
$affectedRows += $referrerFK->save($con);
}
}
}
$this->alreadyInSave = false;
}
return $affectedRows;
}
示例5: addCustomers
static function addCustomers($inputs)
{
/* [customerName] => dasf
[customerEmail] => asdfasdf
[customerMobile] => asdf
[building] => asdf
[apartment] => asdfasdf
[lane] => asdfasdf
[locality] => asdf
[state] => asdfasdf
[city] => asdf
[zipcode] => sdfasdf
[source] => asdfa
[referredBy] => asdf
[introVisit] => on */
$customer = new Customers();
$customer->franchisee_id = Session::get('franchiseId');
$customer->customer_name = $inputs['customerName'];
$customer->customer_lastname = $inputs['customerLastName'];
$customer->customer_email = $inputs['customerEmail'];
$customer->mobile_no = $inputs['customerMobile'];
$customer->building = $inputs['building'];
$customer->apartment_name = $inputs['apartment'];
$customer->lane = $inputs['lane'];
$customer->locality = $inputs['locality'];
$customer->state = $inputs['state'];
$customer->city = $inputs['city'];
$customer->zipcode = $inputs['zipcode'];
$customer->source = $inputs['source'];
$customer->stage = "INIITATED";
if (isset($inputs['eventsId']) && $inputs['eventsId'] != "") {
$customer->source_event = $inputs['eventsId'];
}
$customer->referred_by = $inputs['referredBy'];
$customer->created_by = Session::get('userId');
$customer->created_at = date("Y-m-d H:i:s");
$customer->save();
return $customer;
}
示例6: saveAll
/**
* Save all the data in the database
* @param array $data
* @param integer $id
*/
public static function saveAll(array $data, $id)
{
if (!empty($data) && is_array($data)) {
if (is_numeric($id)) {
$customer = Doctrine::getTable('Customers')->find($id);
if ($customer->customer_id != $id) {
return false;
}
if ($customer->isp_id != Isp::getCurrentId()) {
return false;
}
$customer['created_at'] = date('Y-m-d h:i:s');
} else {
$customer = new Customers();
}
$customer['company'] = $data['company'];
$customer['firstname'] = $data['firstname'];
$customer['lastname'] = $data['lastname'];
$customer['gender'] = $data['gender'];
if (!empty($data['password'])) {
$customer['password'] = crypt($data['password']);
}
$customer['email'] = $data['email'];
$customer['birthplace'] = $data['birthplace'];
$customer['birthdate'] = Shineisp_Commons_Utilities::formatDateIn($data['birthdate']);
$customer['birthdistrict'] = $data['birthdistrict'];
$customer['birthcountry'] = $data['birthcountry'];
$customer['birthnationality'] = $data['birthnationality'];
$customer['note'] = $data['note'];
$customer['vat'] = $data['vat'];
$customer['taxpayernumber'] = $data['taxpayernumber'];
$customer['status_id'] = $data['status_id'];
$customer['issubscriber'] = $data['issubscriber'];
$customer['legalform_id'] = $data['legalform_id'];
$customer['type_id'] = $data['type_id'];
$customer['group_id'] = $data['group_id'];
$customer['issubscriber'] = !empty($data['issubscriber']) ? 1 : 0;
$customer['taxfree'] = !empty($data['taxfree']) ? 1 : 0;
$customer['legalform_id'] = $data['legalform_id'];
$customer['type_id'] = !empty($data['type_id']) ? $data['type_id'] : Null;
$customer['parent_id'] = !empty($data['parent_id']) ? $data['parent_id'] : Null;
$customer['isreseller'] = !empty($data['isreseller']) ? $data['isreseller'] : Null;
$customer['ignore_latefee'] = (bool) $data['ignore_latefee'];
$customer['language_id'] = $data['language_id'];
$customer['updated_at'] = date('Y-m-d h:i:s');
$customer['isp_id'] = Isp::getCurrentId();
$customer->save();
// get the customer ID
$data['customer_id'] = empty($data['customer_id']) ? $customer['customer_id'] : $data['customer_id'];
// Handle the customer address
if (!empty($data['address'])) {
Addresses::AddNew($data);
}
// Handle the customer contact
if (!empty($data['contact'])) {
Contacts::AddNew(array('contact' => $data['contact'], 'type_id' => $data['contacttypes'], 'customer_id' => $customer['customer_id']));
}
// Newsletter OptIn
if (!empty($data['issubscriber']) && $data['issubscriber'] == 1) {
NewslettersSubscribers::customer_optIn($customer['customer_id']);
// Add the customer email in the newsletter list
} else {
NewslettersSubscribers::customer_optOut($customer['customer_id']);
// Remove the customer email from the newsletter subscriber list
}
// Save the upload file
self::UploadDocument($customer['customer_id'], $data['filecategory']);
return $customer['customer_id'];
}
return false;
}
示例7: getCust
public function getCust()
{
$cust = new Customers();
$cust->name = "jethro";
$cust->save();
return "added a record";
}