本文整理汇总了PHP中Customer::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Customer::save方法的具体用法?PHP Customer::save怎么用?PHP Customer::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Customer
的用法示例。
在下文中一共展示了Customer::save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionAddAjax
public function actionAddAjax()
{
if (!isset(Yii::app()->user->storeID)) {
$data['message'] = '<div class="alert alert-success">Store not found. </div>';
echo json_encode($data);
exit;
}
$model = new Customer();
if (isset($_POST['Customer'])) {
$model->attributes = $_POST['Customer'];
$data = array();
$mss = '';
if (count($data) == 0) {
$model->pk_s_id = '-1';
$model->i_flag_sync = 1;
$model->i_flag_deleted = 0;
$model->i_disable = 0;
if ($model->save()) {
$model->pk_s_id = 'SV' . $model->id;
if ($model->save()) {
$data['option'] = '<option selected="selected" value ="' . $model->pk_s_id . '">' . $model->s_name . '</option>';
$data['message'] = '<div class="alert alert-success">Success! Customer created. </div>';
} else {
$model->delete();
$data['message'] = '<div class="alert alert-danger">Error! Please try again later.</div>';
}
} else {
$data['message'] = json_encode($model->errors);
//'<div class="alert alert-danger">Error! Please try again later2.</div>';
}
}
echo json_encode($data);
}
}
示例2: postAddCustomer
public function postAddCustomer()
{
$validator = Validator::make(Input::all(), array('name' => 'required|max:100', 'address' => 'required|max:200', 'number' => 'required|max:100', 'web' => 'required|max:500'));
if ($validator->fails()) {
return Redirect::back()->withErrors($validator)->withInput();
} else {
$email = 'mhnimesh@gmail.com';
$name = Input::get('name');
$address = Input::get('address');
$number = Input::get('number');
$web = Input::get('web');
$customer = new Customer();
$customer->company_name = $name;
$customer->address = $address;
$customer->b_reg_number = $number;
$customer->website = $web;
$insertedToCustomer = $customer->save();
if ($insertedToCustomer) {
$data = array('email' => $email);
Mail::send('email.email', $data, function ($message) use($data) {
$message->to($data['email'])->subject('New Customer Added to the System!');
});
return Redirect::route('dashboard');
} else {
return Redirect::route('customer-add');
}
}
}
示例3: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store()
{
//
$rules = array("customerId" => "required", "firstAddress" => "required", "secondAddress" => "required", "thirdAddress" => "required", "fourthAddress" => "required", "area" => "required", "region" => "required", "customerPhone" => "required|numeric", "customerFax" => "required|numeric", "customerEmail" => "required|email", "customerContact" => "required", "poBirth" => "required|date", "doBirth" => "required|date", "customerReligion" => "required", "customerPosition" => "required", "customerStatus" => "required", "customerChildren" => "required|integer", "customerPhoneHome" => "required|numeric", "customerMobile" => "required|numeric", "customerPinBB" => "required");
$validator = Validator::make(Input::all(), $rules);
if ($validator->fails()) {
return Redirect::to('/customer/create')->withErrors($validator);
}
//
$customer = new Customer();
$customer->customerID = Input::get('customerId');
$customer->customerAddress1 = Input::get('firstAddress');
$customer->customerAddress2 = Input::get('secondAddress');
$customer->customerAddress3 = Input::get('thirdAddress');
$customer->customerAddress4 = Input::get('fourthAddress');
$customer->areaID = Input::get('area');
$customer->regionID = Input::get('region');
$customer->customerPhone = Input::get('customerPhone');
$customer->customerFax = Input::get('customerFax');
$customer->customerEmail = Input::get('customerEmail');
$customer->customerContact = Input::get('customerContact');
$customer->POBirth = Input::get('poBirth');
$customer->DOBirth = Input::get('doBirth');
$customer->customerReligion = Input::get('customerReligion');
$customer->customerPosition = Input::get('customerPosition');
$customer->customerStatus = Input::get('customerStatus');
$customer->customerChildren = Input::get('customerChildren');
$customer->customerPhoneHome = Input::get('customerPhoneHome');
$customer->customerMobile = Input::get('customerMobile');
$customer->customerPinBB = Input::get('customerPinBB');
$customer->save();
return Redirect::to('/customer');
}
示例4: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
die;
$model = new Customer();
// $jaspers_franchise = JaspersFranchise::model()->findAll();
$jaspers_companies = JaspersCompanies::model()->findAllByAttributes(array('franchise_id' => Yii::app()->user->franchise));
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
$bannerImg = Banner::model()->findByAttributes(array('isactive' => 1, 'loc' => 1));
$curUser = User::model()->findByPk(Yii::app()->user->uid);
if (isset($_POST['Customer'])) {
$model->attributes = $_POST['Customer'];
$model->jaspers_franchise = Yii::app()->user->franchise;
$curUser->name = $model->contact;
$curUser->save();
if (Yii::app()->user->isUser()) {
$model->attendee = Yii::app()->user->uid;
$model->franchise = Yii::app()->user->franchise;
}
if ($model->save()) {
Yii::app()->session['last_created_user'] = $model->attributes;
$istApp = new CustAppoint();
$istApp->app_id = 1;
$istApp->cus_id = getCurCusId();
$istApp->status = 0;
$istApp->save();
if (isset($_GET['back'])) {
$this->redirect(array('site/index'));
}
//$this->redirect(array('site/getstarted', 'id' => getCurCusId()));
$this->redirect(array('workingwell/create', 'id' => getCurCusId()));
}
}
$this->render('create', array('model' => $model, 'bannerImg' => $bannerImg, 'curUser' => $curUser, 'jaspers_companies' => $jaspers_companies));
}
示例5: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
$model = new Customer();
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if (isset($_POST['Customer'])) {
$model->attributes = $_POST['Customer'];
if ($model->save()) {
// Comprobamos si existe la lista de envio de todos los clientes
if (count(Mailist::model()->findByAttributes(array('Name' => 'Todos los clientes', 'UserID' => Yii::app()->user->ID)))) {
// Si existe la lista añadimos el nuevo cliente
$ListID = Mailist::model()->findByAttributes(array('Name' => 'Todos los clientes'))->ID;
$modelCustomerList = new CustomerList();
$modelCustomerList->UserID = Yii::app()->user->ID;
$modelCustomerList->ListID = $ListID;
$modelCustomerList->CustomerID = $model->ID;
$modelCustomerList->save();
} else {
// Si no existe la lista la creamos y añadimos el cliente nuevo
$modelMailist = new Mailist();
$modelMailist->Name = "Todos los clientes";
$modelMailist->UserID = Yii::app()->user->ID;
if ($modelMailist->save()) {
$modelCustomerList = new CustomerList();
$modelCustomerList->UserID = Yii::app()->user->ID;
$modelCustomerList->ListID = $modelMailist->ID;
$modelCustomerList->CustomerID = $model->ID;
$modelCustomerList->save();
}
}
$this->redirect(array('admin'));
}
}
$this->render('create', array('model' => $model));
}
示例6: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
$model = new Invoice();
$modelCustomer = new Customer();
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if (isset($_POST['Invoice'])) {
$model->attributes = $_POST['Invoice'];
// Si creamos un nuevo Customer hay que guardarlo
if (strlen($model->CustomerID) == 0) {
$modelCustomer->attributes = $_POST['Customer'];
if ($modelCustomer->save()) {
$model->CustomerID = $modelCustomer->ID;
}
} else {
$modelCustomer = Customer::model()->findByPK($model->CustomerID);
$modelCustomer->attributes = $_POST['Customer'];
$modelCustomer->save();
}
if ($model->save()) {
$this->redirect(array('admin'));
}
}
$this->render('create', array('model' => $model, 'modelCustomer' => $modelCustomer));
}
示例7: actionCreate
public function actionCreate()
{
if ($model = Shop::getCustomer()) {
$address = $model->address;
} else {
$model = new Customer();
}
if (isset($_POST['Customer'])) {
$model->attributes = $_POST['Customer'];
if (isset($_POST['Address'])) {
$address = new Address();
$address->attributes = $_POST['Address'];
if ($address->save()) {
$model->address_id = $address->id;
}
}
if (!Yii::app()->user->isGuest) {
$model->user_id = Yii::app()->user->id;
}
if ($model->save()) {
Yii::app()->user->setState('customer_id', $model->customer_id);
$this->redirect(array('//shop/order/create', 'customer' => $model->customer_id));
}
}
$this->render('create', array('customer' => $model, 'address' => isset($address) ? $address : new Address()));
}
示例8: createCustomer
public function createCustomer()
{
// $dbcustomer = new Customer($customer);
$rule = array('first_name' => 'required', 'email' => 'email|required');
$cust = Input::all();
$valid = Validator::make($cust, $rule);
if ($valid->fails()) {
return Redirect::to('add-customer');
} else {
$customer = new Customer();
$customer->first_name = Input::get('first_name');
$customer->last_name = Input::get('last_name');
$customer->email = Input::get('email');
$customer->phone_no = Input::get('phone_no');
$customer->address_1 = Input::get('address_1');
$customer->address_2 = Input::get('address_2');
$customer->city = Input::get('city');
$customer->state = Input::get('state');
$customer->zip = Input::get('zip');
$customer->country = Input::get('country');
$customer->comment = Input::get('comment');
$customer->account = Input::get('account');
$customer->save();
return Redirect::to('all-customers');
}
}
示例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 ConnectionInterface $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(ConnectionInterface $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->aCustomer !== null) {
if ($this->aCustomer->isModified() || $this->aCustomer->isNew()) {
$affectedRows += $this->aCustomer->save($con);
}
$this->setCustomer($this->aCustomer);
}
if ($this->isNew() || $this->isModified()) {
// persist changes
if ($this->isNew()) {
$this->doInsert($con);
} else {
$this->doUpdate($con);
}
$affectedRows += 1;
$this->resetModified();
}
$this->alreadyInSave = false;
}
return $affectedRows;
}
示例10: actionCreate
public function actionCreate()
{
// if some data has been entered before or the user is already logged in,
// take the already existing data and prefill the input form
if ($model = Shop::getCustomer()) {
$address = $model->address;
} else {
$model = new Customer();
}
if (isset($_POST['Customer'])) {
$model->attributes = $_POST['Customer'];
if (isset($_POST['Address'])) {
$address = new Address();
$address->attributes = $_POST['Address'];
if ($address->save()) {
$model->address_id = $address->id;
}
}
if (!Yii::app()->user->isGuest) {
$model->user_id = Yii::app()->user->id;
}
$model->validate();
if (Shop::module()->useWithYum && isset($_POST['register']) && ($_POST['register'] = true)) {
if (isset($_POST['Customer']['password']) && isset($_POST['Customer']['passwordRepeat'])) {
if ($_POST['Customer']['password'] != $_POST['Customer']['passwordRepeat']) {
$model->addError('password', Shop::t('Passwords do not match'));
} else {
if ($_POST['Customer']['password'] == '') {
$model->addError('password', Shop::t('Password is empty'));
} else {
$user = new YumUser();
$profile = new YumProfile();
$profile->attributes = $_POST['Customer'];
$profile->attributes = $_POST['Address'];
if ($user->register(strtr($model->email, array('@' => '_', '.' => '_')), $_POST['Customer']['password'], $profile)) {
$user->status = YumUser::STATUS_ACTIVE;
$user->save(false, array('status'));
$model->user_id = $user->id;
Shop::setFlash(Shop::t('Successfully registered user'));
} else {
$model->addErrors($user->getErrors());
$model->addErrors($profile->getErrors());
Shop::setFlash(Shop::t('Error while registering user'));
}
}
}
}
}
if (!$model->hasErrors()) {
if ($model->save()) {
Yii::app()->user->setState('customer_id', $model->customer_id);
$this->redirect(array('//shop/order/create', 'customer' => $model->customer_id));
}
}
}
$this->render('create', array('customer' => $model, 'address' => isset($address) ? $address : new Address()));
}
示例11: actionRegister
public function actionRegister()
{
$model = new Customer();
if (isset($_POST['Customer'])) {
$model->attributes = $_POST['Customer'];
if ($model->save()) {
$this->redirect(array('account/'));
}
}
$this->render('register', array("model" => $model));
}
示例12: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
$model = new Customer();
$contact = new Contact();
// Uncomment the following line if AJAX validation is needed
$this->performAjaxValidation(array($model, $contact));
if ($model->save(false)) {
$this->redirect(array('update', 'id' => $model->id));
}
$this->render('create', array('model' => $model, 'contact' => $contact));
}
示例13: action_do_create
public function action_do_create()
{
$v = Customer::validate(Input::all());
if ($v->fails()) {
return Redirect::to_route('create_customer')->with('user', Auth::user())->with_errors($v)->with_input();
}
$new_customer = array('name' => Input::get('name'), 'description' => Input::get('description'), 'organization_id' => Auth::user()->organization->id);
$customer = new Customer($new_customer);
$customer->save();
return Redirect::to_route('customers');
}
示例14: __construct
/** Override __construct() because we're not passing user/pass
*/
public function __construct()
{
$user = new Customer();
$user->record_type = Customer::GUEST;
$user->last_login = new CDbExpression('NOW()');
if ($user->save() === false) {
print_r($user->getErrors());
}
$this->setState('fullname', 'Guest');
$this->setState('firstname', 'Guest');
$this->_id = $user->id;
}
示例15: actionAddCustomer
public function actionAddCustomer()
{
$data = CJSON::decode(file_get_contents('php://input'));
$customer = new Customer();
$customer->attributes = $data;
if ($customer->save()) {
$this->renderJSON($customer);
} else {
$response = array('success' => false, 'message' => 'Couldn\'t save customer');
$this->renderJSON($response);
}
}