本文整理汇总了PHP中Facilities::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Facilities::save方法的具体用法?PHP Facilities::save怎么用?PHP Facilities::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Facilities
的用法示例。
在下文中一共展示了Facilities::save方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _add
private function _add()
{
use_helper('Validate');
$data = $_POST['facilities'];
Flash::set('facilities_postdata', $data);
// Add pre-save checks here
$errors = false;
// CSRF checks
if (isset($_POST['csrf_token'])) {
$csrf_token = $_POST['csrf_token'];
if (!SecureToken::validateToken($csrf_token, BASE_URL . 'facilities/add')) {
Flash::set('error', __('Invalid CSRF token found!'));
redirect(get_url('facilities/add'));
}
} else {
Flash::set('error', __('No CSRF token found!'));
redirect(get_url('facilities/add'));
}
if (empty($data['name'])) {
Flash::set('error', __('You have to specify a facilities name!'));
redirect(get_url('facilities/add'));
}
if ($errors !== false) {
// Set the errors to be displayed.
Flash::set('error', implode('<br/>', $errors));
redirect(get_url('facilities/add'));
}
$new_facilities = new Facilities($data);
$new_facilities->created_by_id = AuthUser::getId();
$new_facilities->created_on = date('Y-m-d H:i:s');
if ($new_facilities->save()) {
if (isset($_FILES)) {
if (strlen($_FILES['upload_file']['name']) > 0) {
$facilities_id = $new_facilities->lastInsertId();
$overwrite = false;
$file = $this->upload_pdf_file($facilities_id, $_FILES['upload_file']['name'], FILES_DIR . '/facilities/images/', $_FILES['upload_file']['tmp_name'], $overwrite);
if ($file === false) {
Flash::set('error', __('File has not been uploaded!'));
}
redirect(get_url('facilities/edit/' . $new_facilities->id));
}
}
Flash::set('success', __('Facilities has been added!'));
Observer::notify('facilities_after_add', $new_facilities->name);
// save and quit or save and continue editing?
if (isset($_POST['commit'])) {
redirect(get_url('facilities'));
} else {
redirect(get_url('facilities/edit/' . $new_facilities->id));
}
} else {
Flash::set('error', __('Facilities has not been added!'));
redirect(get_url('facilities/add'));
}
}
示例2: save_details
public function save_details()
{
$district = $this->session->userdata("district_province_id");
$facility_id = $this->input->post('facility_id');
//Check if we are in editing mode first; if so, retrieve the edited record. if not, create a new one!
if (strlen($facility_id) > 0) {
$facility = Facilities::getFacility($facility_id);
//Retrieve the fridges for this facility
$fridges = Facility_Fridges::getFacilityFridges($facility_id);
//Delete all these existing facility-fridge combinations
foreach ($fridges as $fridge) {
$fridge->delete();
}
} else {
$facility = new Facilities();
}
$facility->facilitycode = $this->input->post('facilitycode');
$facility->name = $this->input->post('name');
$facility->facilitytype = $this->input->post('type');
$facility->district = $district;
$facility->email = $this->input->post('email');
$facility->phone = $this->input->post('phone');
$facility->save();
$facility_id = $facility->id;
$fridges = $this->input->post('fridges');
$counter = 0;
foreach ($fridges as $fridge) {
if ($fridge > 0) {
$facility_fridge = new Facility_Fridges();
$facility_fridge->Facility = $facility_id;
$facility_fridge->Fridge = $fridge;
$facility_fridge->Timestamp = date('U');
$facility_fridge->save();
$counter++;
} else {
$counter++;
continue;
}
}
redirect("facility_management/district_list");
}