/** * Store a newly created resource in storage. * POST /familylaws * * @return Response */ public function store() { $validator = Family::validate(Input::only('name', 'description')); if ($validator->fails()) { return Redirect::to('/allfamilyLaws')->withErrors($validator)->withInput(Input::all()); } else { $family = new Family(); $family->name = Input::get('name'); $family->description = Input::get('description'); $family->save(); return Redirect::to('allfamilyLaws')->with('message', 'Family Law Practice Area was successfully created'); } }
/** * 录入 * */ public function actionCreate() { parent::_acl(); $model = new Family(); $imageList = $this->_gets->getPost('imageList'); $imageListSerialize = XUtils::imageListSerialize($imageList); if (isset($_POST['Family'])) { $acl = $this->_gets->getPost('acl'); $model->attributes = $_POST['Family']; $model->actual_people = 0; $model->pic_other = $imageListSerialize['dataSerialize']; if ($model->save()) { AdminLogger::_create(array('catalog' => 'create', 'intro' => '录入内容,ID:' . $model->id)); $this->redirect(array('index')); } } $this->render('family_create', array('model' => $model, 'imageList' => $imageListSerialize['data'])); }
function family($employee_id = '') { $data['page_name'] = '<b>Personal Data Sheet</b>'; $data['section_name'] = '<b>Personal Information</b>'; $data['focus_field'] = 'spouse_lname'; $data['msg'] = ''; $e = new Employee_m(); $data['employee'] = $e->get_by_id($employee_id); $family = new Family(); if (Input::get('op')) { $family->get_by_employee_id($employee_id); $family->employee_id = $employee_id; $family->spouse_lname = Input::get('spouse_lname'); $family->spouse_fname = Input::get('spouse_fname'); $family->spouse_mname = Input::get('spouse_mname'); $family->spouse_occupation = Input::get('spouse_occupation'); $family->spouse_employer = Input::get('spouse_employer'); $family->spouse_biz_ad = Input::get('spouse_biz_ad'); $family->spouse_tel = Input::get('spouse_tel'); $family->father_lname = Input::get('father_lname'); $family->father_fname = Input::get('father_fname'); $family->father_mname = Input::get('father_mname'); $family->mother_lname = Input::get('mother_lname'); $family->mother_fname = Input::get('mother_fname'); $family->mother_mname = Input::get('mother_mname'); $family->save(); // Children $c = new Children(); $c->get_by_employee_id($employee_id); $c->delete_all(); $children = Input::get('children'); $children_birth_day = Input::get('children_birth_day'); $i = 0; foreach ($children as $child) { if ($child != "") { $c = new Children(); $c->employee_id = $employee_id; $c->children = $children[$i]; $c->birth_date = $children_birth_day[$i]; $c->save(); } $i++; } $data['msg'] = 'Family Background has been saved!'; } $family = new Family(); $data['family'] = $family->get_by_employee_id($employee_id); // Children=================================================== $children = new Children(); $children->order_by('birth_date'); $children = $children->get_by_employee_id($employee_id); $i = 0; foreach ($children as $child) { $data['children']['name'][] = $child->children; $data['children']['birth_date'][] = $child->birth_date; $i++; } if ($i <= 14) { while ($i != 14) { $data['children']['name'][] = ''; $data['children']['birth_date'][] = ''; $i++; } } $data['selected'] = $e->office_id; // Use for office listbox $data['options'] = $this->options->office_options(); $data['employee_id'] = $employee_id; $data['main_content'] = 'family'; return View::make('includes/template', $data); }
/** * @before _secure */ public function addFamily() { $this->JSONview(); $view = $this->getActionView(); if (RequestMethods::post("action") == "patient") { $email = RequestMethods::post("email"); $patient = null; if (strlen($email) > 4) { $patient = User::first(array("email = ?" => $email)); $m = "Email exists enter a different email"; } $phone = RequestMethods::post("phone", ""); if (strlen($phone) >= 10) { $patient = User::first(array("phone = ?" => $phone)); $m = "Phone already exists please choose a different one"; } if ($patient) { $view->set("success", false); $view->set("message", $m); return; } $patient = new User(array("name" => RequestMethods::post("name", ""), "email" => $email, "phone" => $phone, "password" => sha1($this->randomPassword()), "gender" => RequestMethods::post("gender", ""), "birthday" => RequestMethods::post("birthday", ""), "live" => 1)); $patient->save(); $family = new Family(array("user_id" => $this->user->id, "member_id" => $patient->id, "relation" => RequestMethods::post("relation"))); $family->save(); Location::saveRecord($patient); if ($email) { Mail::notify(array("template" => "notifyFamily", "subject" => "Getting Started on HealthLitmus.com", "user" => $patient, "patient" => $patient, "member" => $this->user, "family" => $family)); } Mail::notify(array("template" => "addFamily", "subject" => "New Beneficiary Added {$patient->name} on HealthLitmus.com", "user" => $this->user, "mail" => $email, "patient" => $patient, "family" => $family)); $fs = Shared\Services\Patient::findFamily($this->user); $view->set("patient", $patient); $view->set("families", $fs); $view->set("success", true); } //$this->redirect($_SERVER['HTTP_REFERER']); }
function save() { $family = new Family(); $staff_id = $this->uri->segment(2); $family->staff_fam_staff_id = $staff_id; $family->staff_fam_order = $this->input->post('staff_fam_order'); $family->staff_fam_name = $this->input->post('staff_fam_name'); $family->staff_fam_birthdate = $this->input->post('staff_fam_birthdate'); $family->staff_fam_birthplace = $this->input->post('staff_fam_birthplace'); $family->staff_fam_sex = $this->input->post('staff_fam_sex'); $family->staff_fam_relation = $this->input->post('staff_fam_relation'); if ($family->save()) { $this->session->set_flashdata('message', 'Family successfully created!'); redirect('staffs/' . $staff_id . '/families/index'); } else { // Failed $family->error_message('custom', 'Field required'); $msg = $family->error->custom; $this->session->set_flashdata('message', $msg); redirect('staff/' . $staff_id . '/families/add'); } }
/** * Add a family * * @param string $passkey * @param string $strFamily * @return string */ public function add_family($passkey, $strFamily) { if (!$this->check_passkey($passkey)) { return self::FAIL_AUTH; } if (trim($strFamily) == '') { //ignore blank families return self::OK; } $family = Family::LoadByFamily($strFamily); if (!$family) { $family = new Family(); } $family->family = $strFamily; $family->request_url = _xls_seo_url($strFamily); if (!$family->save()) { Yii::log("SOAP ERROR : Error saving family {$strFamily} " . print_r($family->getErrors()), 'error', 'application.' . __CLASS__ . "." . __FUNCTION__); return self::UNKNOWN_ERROR . " Error saving family {$strFamily} " . print_r($family->getErrors(), true); } return self::OK; }
/** * Save a product in the database (Create if need be) * * @param string $passkey * @param int $intRowid * @param string $strCode * @param string $strName * @param string $blbImage * @param string $strClassName * @param int $blnCurrent * @param string $strDescription * @param string $strDescriptionShort * @param string $strFamily * @param int $blnGiftCard * @param int $blnInventoried * @param double $fltInventory * @param double $fltInventoryTotal * @param int $blnMasterModel * @param int $intMasterId * @param string $strProductColor * @param string $strProductSize * @param double $fltProductHeight * @param double $fltProductLength * @param double $fltProductWidth * @param double $fltProductWeight * @param int $intTaxStatusId * @param double $fltSell * @param double $fltSellTaxInclusive * @param double $fltSellWeb * @param string $strUpc * @param int $blnOnWeb * @param string $strWebKeyword1 * @param string $strWebKeyword2 * @param string $strWebKeyword3 * @param int $blnFeatured * @param int $intCategoryId * @return string * @throws SoapFault * * @soap */ public function save_product($passkey, $intRowid, $strCode, $strName, $blbImage, $strClassName, $blnCurrent, $strDescription, $strDescriptionShort, $strFamily, $blnGiftCard, $blnInventoried, $fltInventory, $fltInventoryTotal, $blnMasterModel, $intMasterId, $strProductColor, $strProductSize, $fltProductHeight, $fltProductLength, $fltProductWidth, $fltProductWeight, $intTaxStatusId, $fltSell, $fltSellTaxInclusive, $fltSellWeb, $strUpc, $blnOnWeb, $strWebKeyword1, $strWebKeyword2, $strWebKeyword3, $blnFeatured, $intCategoryId) { self::check_passkey($passkey); // We must preservice the Rowid of Products within the Web Store // database and must therefore see if it already exists $objProduct = Product::model()->findByPk($intRowid); if (!$objProduct) { $objProduct = new Product(); $objProduct->id = $intRowid; } $strName = trim($strName); $strName = trim($strName, '-'); $strName = substr($strName, 0, 255); $strCode = trim($strCode); $strCode = str_replace('"', '', $strCode); $strCode = str_replace("'", '', $strCode); if (empty($strName)) { $strName = 'missing-name'; } if (empty($strDescription)) { $strDescription = ''; } $objProduct->code = $strCode; $objProduct->title = $strName; //$objProduct->class_name = $strClassName; $objProduct->current = $blnCurrent; $objProduct->description_long = $strDescription; $objProduct->description_short = $strDescriptionShort; //$objProduct->family = $strFamily; $objProduct->gift_card = $blnGiftCard; $objProduct->inventoried = $blnInventoried; $objProduct->inventory = $fltInventory; $objProduct->inventory_total = $fltInventoryTotal; $objProduct->master_model = $blnMasterModel; if ($intMasterId > 0) { $objProduct->parent = $intMasterId; } else { $objProduct->parent = null; } $objProduct->product_color = $strProductColor; $objProduct->product_size = $strProductSize; $objProduct->product_height = $fltProductHeight; $objProduct->product_length = $fltProductLength; $objProduct->product_width = $fltProductWidth; $objProduct->product_weight = $fltProductWeight; $objProduct->tax_status_id = $intTaxStatusId; $objProduct->sell = $fltSell; $objProduct->sell_tax_inclusive = $fltSellTaxInclusive; //If we're in TaxIn Mode, then SellWeb has tax and we reverse it. if (_xls_get_conf('TAX_INCLUSIVE_PRICING', 0) == 1) { if ($fltSellWeb != 0) { //Tax in with a sell on web price $objProduct->sell_web_tax_inclusive = $fltSellWeb; //LS sends tax in web already $objProduct->sell_web = Tax::StripTaxesFromPrice($fltSellWeb, $intTaxStatusId); } else { //We use our regular prices and copy them price $objProduct->sell_web_tax_inclusive = $fltSellTaxInclusive; $objProduct->sell_web = $fltSell; } } else { if ($fltSellWeb != 0) { $objProduct->sell_web = $fltSellWeb; } else { $objProduct->sell_web = $fltSell; } } $objProduct->upc = $strUpc; $objProduct->web = $blnOnWeb; $objProduct->featured = $blnFeatured; $fltReserved = $objProduct->CalculateReservedInventory(); $objProduct->inventory_reserved = $fltReserved; if (_xls_get_conf('INVENTORY_FIELD_TOTAL', 0) == 1) { $objProduct->inventory_avail = $fltInventoryTotal - $fltReserved; } else { $objProduct->inventory_avail = $fltInventory - $fltReserved; } //Because Lightspeed may send us products out of sequence (child before parent), we have to turn this off Yii::app()->db->createCommand('SET FOREIGN_KEY_CHECKS=0;')->execute(); if (!$objProduct->save()) { $strMsg = "Error saving product {$intRowid} {$strCode}"; Yii::log("SOAP ERROR : {$strMsg} " . print_r($objProduct->getErrors(), true), CLogger::LEVEL_ERROR, 'application.' . __CLASS__ . "." . __FUNCTION__); Yii::log("Product attributes: " . CVarDumper::dumpAsString($objProduct), CLogger::LEVEL_INFO, 'application.' . __CLASS__ . "." . __FUNCTION__); throw new SoapFault($strMsg, WsSoapException::ERROR_UNKNOWN); } $strFeatured = _xls_get_conf('FEATURED_KEYWORD', 'XnotsetX'); if (empty($strFeatured)) { $strFeatured = 'XnotsetX'; } //Save keywords $strTags = trim($strWebKeyword1) . "," . trim($strWebKeyword2) . "," . trim($strWebKeyword3); $strTags = str_replace(",,", ",", $strTags); $arrTags = explode(",", $strTags); ProductTags::DeleteProductTags($objProduct->id); foreach ($arrTags as $indivTag) { if (!empty($indivTag)) { $tag = Tags::model()->findByAttributes(array('tag' => $indivTag)); if (!$tag instanceof Tags) { $tag = new Tags(); $tag->tag = $indivTag; $tag->save(); } $objProductTag = new ProductTags(); $objProductTag->product_id = $objProduct->id; $objProductTag->tag_id = $tag->id; $objProductTag->save(); if ($strFeatured != 'XnotsetX' && $objProduct->web && $indivTag == $strFeatured) { $objProduct->featured = 1; $objProduct->save(); } } } if (!empty($strFamily)) { $objFamily = Family::model()->findByAttributes(array('family' => $strFamily)); if ($objFamily instanceof Family) { $objProduct->family_id = $objFamily->id; $objProduct->save(); } else { $objFamily = new Family(); $objFamily->family = $strFamily; $objFamily->child_count = 0; $objFamily->request_url = _xls_seo_url($strFamily); $objFamily->save(); $objProduct->family_id = $objFamily->id; $objProduct->save(); } $objFamily->UpdateChildCount(); } else { if ($objProduct->family_id) { $objFamily = Family::model()->findByAttributes(array('id' => $objProduct->family_id)); $objProduct->family_id = null; $objProduct->save(); $objFamily->UpdateChildCount(); } } if (!empty($strClassName)) { $objClass = Classes::model()->findByAttributes(array('class_name' => $strClassName)); if ($objClass instanceof Classes) { $objProduct->class_id = $objClass->id; $objProduct->save(); } else { $objClass = new Classes(); $objClass->class_name = $strClassName; $objClass->child_count = 0; $objClass->request_url = _xls_seo_url($strClassName); $objClass->save(); $objProduct->class_id = $objClass->id; $objProduct->save(); } $objClass->UpdateChildCount(); } // Assign the product category. // Delete any prior category from the product. ProductCategoryAssn::model()->deleteAllByAttributes(array('product_id' => $objProduct->id)); // A categoryId of 0 indicates that the Item is not assigned to a category. if ($intCategoryId !== 0) { $objCategory = Category::model()->findByPk($intCategoryId); if ($objCategory === null) { Yii::log('Unable to find matching category.', 'error', 'application.' . __CLASS__ . "." . __FUNCTION__); } else { $objAssn = new ProductCategoryAssn(); $objAssn->product_id = $objProduct->id; $objAssn->category_id = $intCategoryId; $objAssn->save(); $objCategory->UpdateChildCount(); } } Product::convertSEO($intRowid); //Build request_url Yii::app()->db->createCommand('SET FOREIGN_KEY_CHECKS=1;')->execute(); $objEvent = new CEventProduct('LegacysoapController', 'onSaveProduct', $objProduct); _xls_raise_events('CEventProduct', $objEvent); return self::OK; }