function handleFormData($edit_submit = false) { global $template, $WebBaseDir, $i18n, $ActiveOption, $ClassDir, $UploadDir, $AllowUploadFilesType, $AddIP, $userid, $group_ids; $apf_product = DB_DataObject::factory('ApfProduct'); if ($edit_submit) { $apf_product->get($apf_product->escape($_POST['ID'])); $do_action = "updatesubmit"; } else { $do_action = "addsubmit"; } $apf_product->setCategory(stripslashes(trim($_POST['category']))); $apf_product->setCompanyId(stripslashes(trim($_POST['company_id']))); $apf_product->setName(stripslashes(trim($_POST['name']))); $apf_product->setPrice(stripslashes(trim($_POST['price']))); $apf_product->setMemo(stripslashes(trim($_POST['memo']))); $apf_product->setActive(stripslashes(trim($_POST['active']))); $apf_product->setAddIp($AddIP); $apf_product->setGroupid($group_ids); $apf_product->setUserid($userid); if ($_POST['photo_del'] == 'Y') { unlink($UploadDir . $_POST['photo_old']); $apf_product->setPhoto(""); $_POST['photo_old'] = ""; } if ($_POST['upload_temp']) { $apf_product->setPhoto($_POST['upload_temp']); } $allow_upload_file = TRUE; if ($_FILES['photo']['name']) { require_once $ClassDir . "FileHelper.class.php"; $upload_data = FileHelper::uploadFile("product"); $allow_upload_file = $upload_data["upload_state"]; if ($allow_upload_file) { $photos_arr = $upload_data["upload_msg"]; if ($photo_pic = $photos_arr['photo']) { $apf_product->setPhoto($photo_pic); $_POST['upload_temp'] = $photo_pic; } } else { $upload_error_msg = $upload_data["upload_msg"]; } } $val = $apf_product->validate(); if ($val === TRUE && $allow_upload_file === TRUE) { if ($edit_submit) { $apf_product->setUpdateAt(DB_DataObject_Cast::dateTime()); $apf_product->update(); $log_string = $i18n->_("Update") . $i18n->_("Product") . "\t{$_POST['name']}=>{$_POST['ID']}"; logFileString($log_string); $this->forward("product/apf_product/update/" . $_POST['ID'] . "/ok"); } else { $apf_product->setCreatedAt(DB_DataObject_Cast::dateTime()); $apf_product->insert(); $log_string = $i18n->_("Create") . $i18n->_("Product") . "\t{$_POST['name']}"; logFileString($log_string); $this->forward("product/apf_product/"); } } else { $template->setFile(array("MAIN" => "apf_product_edit.html")); $template->setBlock("MAIN", "edit_block"); $template->setVar(array("WEBDIR" => $WebBaseDir, "DOACTION" => $do_action)); $category_arr = $this->getCategory(); array_shift($ActiveOption); $template->setVar(array("CATEGORYOPTION" => selectTag("category", $category_arr, $_POST['category']), "FILEPHOTO" => fileTag("photo", $_POST['photo_old']), "ACTIVEOPTION" => radioTag("active", $ActiveOption, $_POST['active']))); foreach ($val as $k => $v) { if ($v == false) { $template->setVar(array(strtoupper($k) . "_ERROR_MSG" => " ↓ " . $i18n->_("Please check here") . " ↓ ")); } } $template->setVar(array("ID" => $_POST['id'], "CATEGORY" => $_POST['category'], "COMPANY_ID" => $_POST['company_id'], "NAME" => $_POST['name'], "PRICE" => $_POST['price'], "PHOTO" => $_POST['photo'], "MEMO" => $_POST['memo'], "ACTIVE" => $_POST['active'], "ADD_IP" => $_POST['add_ip'], "CREATED_AT" => $_POST['created_at'], "UPDATE_AT" => $_POST['update_at'])); } }
function handleFormData($edit_submit = false) { global $template, $WebBaseDir, $i18n, $UploadDir, $ClassDir, $AddIP, $userid, $group_ids; $apf_selfcompany = DB_DataObject::factory('ApfSelfcompany'); if ($edit_submit) { $apf_selfcompany->get($apf_selfcompany->escape($_POST['ID'])); $do_action = "updatesubmit"; } else { $do_action = "addsubmit"; } $apf_selfcompany->setName(stripslashes(trim($_POST['name']))); $apf_selfcompany->setAddrees(stripslashes(trim($_POST['addrees']))); $apf_selfcompany->setPhone(stripslashes(trim($_POST['phone']))); $apf_selfcompany->setFax(stripslashes(trim($_POST['fax']))); $apf_selfcompany->setEmail(stripslashes(trim($_POST['email']))); $apf_selfcompany->setHomepage(stripslashes(trim($_POST['homepage']))); $apf_selfcompany->setEmployee(stripslashes(trim($_POST['employee']))); $apf_selfcompany->setBankroll(stripslashes(trim($_POST['bankroll']))); $apf_selfcompany->setLinkMan(stripslashes(trim($_POST['link_man']))); $apf_selfcompany->setIncorporator(stripslashes(trim($_POST['incorporator']))); $apf_selfcompany->setIndustry(stripslashes(trim($_POST['industry']))); $apf_selfcompany->setTaxaccounts(stripslashes(trim($_POST['taxaccounts']))); $apf_selfcompany->setBankaccounts(stripslashes(trim($_POST['bankaccounts']))); $apf_selfcompany->setProducts(stripslashes(trim($_POST['products']))); $apf_selfcompany->setMemo(stripslashes(trim($_POST['memo']))); $apf_selfcompany->setActive(stripslashes(trim($_POST['active']))); $apf_selfcompany->setAccess(stripslashes(trim($_POST['access']))); $apf_selfcompany->setAddIp($AddIP); $apf_selfcompany->setGroupid($group_ids); $apf_selfcompany->setUserid($userid); if ($_POST['photo_del'] == 'Y') { unlink($UploadDir . $_POST['photo_old']); $apf_selfcompany->setPhoto(""); $_POST['photo_old'] = ""; } if ($_POST['upload_temp']) { $apf_selfcompany->setPhoto($_POST['upload_temp']); } $allow_upload_file = TRUE; if ($_FILES['photo']['name']) { require_once $ClassDir . "FileHelper.class.php"; $upload_data = FileHelper::uploadFile("product"); $allow_upload_file = $upload_data["upload_state"]; if ($allow_upload_file) { $photos_arr = $upload_data["upload_msg"]; if ($photo_pic = $photos_arr['photo']) { $apf_selfcompany->setPhoto($photo_pic); $_POST['upload_temp'] = $photo_pic; } } else { $upload_error_msg = $upload_data["upload_msg"]; } } $val = $apf_selfcompany->validate(); if ($val === TRUE && $allow_upload_file === TRUE) { if ($edit_submit) { $apf_selfcompany->setUpdateAt(DB_DataObject_Cast::dateTime()); $apf_selfcompany->update(); $log_string = $i18n->_("Update") . $i18n->_("ModuleName") . "\t{$_POST['name']}=>{$_POST['ID']}"; logFileString($log_string); $this->forward("selfcompany/apf_selfcompany/update/" . $_POST['ID'] . "/ok"); } else { $apf_selfcompany->setCreatedAt(DB_DataObject_Cast::dateTime()); $apf_selfcompany->insert(); $log_string = $i18n->_("Create") . $i18n->_("ModuleName") . "\t{$_POST['name']}=>{$_POST['create_date']}"; logFileString($log_string); $this->forward("selfcompany/apf_selfcompany/"); } } else { $template->setFile(array("MAIN" => "apf_selfcompany_edit.html")); $template->setBlock("MAIN", "edit_block"); $template->setVar(array("WEBDIR" => $WebBaseDir, "DOACTION" => $do_action)); foreach ($val as $k => $v) { if ($v == false) { $template->setVar(array(strtoupper($k) . "_ERROR_MSG" => " ↓ " . $i18n->_("Please check here") . " ↓ ")); } } $template->setVar(array("ID" => $_POST['id'], "NAME" => $_POST['name'], "ADDREES" => $_POST['addrees'], "PHONE" => $_POST['phone'], "FAX" => $_POST['fax'], "EMAIL" => $_POST['email'], "PHOTO" => $_POST['photo'], "HOMEPAGE" => $_POST['homepage'], "EMPLOYEE" => $_POST['employee'], "BANKROLL" => $_POST['bankroll'], "LINK_MAN" => $_POST['link_man'], "INCORPORATOR" => $_POST['incorporator'], "INDUSTRY" => $_POST['industry'], "TAXACCOUNTS" => $_POST['taxaccounts'], "BANKACCOUNTS" => $_POST['bankaccounts'], "PRODUCTS" => $_POST['products'], "MEMO" => $_POST['memo'], "ACTIVE" => $_POST['active'], "ACCESS" => $_POST['access'], "GROUPID" => $_POST['groupid'], "USERID" => $_POST['userid'], "ADD_IP" => $_POST['add_ip'], "CREATED_AT" => $_POST['created_at'], "UPDATE_AT" => $_POST['update_at'])); } }
function handleFormData($edit_submit = false) { global $template, $WebBaseDir, $i18n, $TimeOption, $ActiveOption, $AddIP, $userid, $group_ids, $ClassDir, $UploadDir; $apf_schedule = DB_DataObject::factory('ApfSchedule'); if ($edit_submit) { $apf_schedule->get($apf_schedule->escape($_POST['ID'])); $do_action = "updatesubmit"; } else { $do_action = "addsubmit"; } $apf_schedule->setTitle(stripslashes(trim($_POST['title']))); $apf_schedule->setDescription(stripslashes(trim($_POST['description']))); $apf_schedule->setPublishDate(DB_DataObject_Cast::date(stripslashes(trim($_POST['publish_date'])))); $apf_schedule->setPublishStarttime(DB_DataObject_Cast::time(stripslashes(trim($_POST['publish_starttime'])))); $apf_schedule->setPublishEndtime(DB_DataObject_Cast::time(stripslashes(trim($_POST['publish_endtime'])))); $apf_schedule->setImage(stripslashes(trim($_POST['image']))); $apf_schedule->setActive(stripslashes(trim($_POST['active']))); $apf_schedule->setAddIp($AddIP); $apf_schedule->setGroupid($group_ids); $apf_schedule->setUserid($userid); if ($_POST['image_del'] == 'Y') { unlink($UploadDir . $_POST['image_old']); $apf_schedule->setImage(""); $_POST['image_old'] = ""; } if ($_POST['upload_temp']) { $apf_schedule->setImage($_POST['upload_temp']); } $allow_upload_file = TRUE; if ($_FILES['image']['name']) { require_once $ClassDir . "FileHelper.class.php"; $upload_data = FileHelper::uploadFile("schedule"); $allow_upload_file = $upload_data["upload_state"]; if ($allow_upload_file) { $images_arr = $upload_data["upload_msg"]; if ($image_pic = $images_arr['image']) { $apf_schedule->setImage($image_pic); $_POST['upload_temp'] = $image_pic; } } else { $upload_error_msg = $upload_data["upload_msg"]; } } $val = $apf_schedule->validate(); if ($val === TRUE && $allow_upload_file === TRUE) { if ($edit_submit) { $apf_schedule->setUpdateAt(DB_DataObject_Cast::dateTime()); $apf_schedule->update(); $log_string = $i18n->_("Update") . $i18n->_("Schedule") . "\t{$_POST['title']}=>{$_POST['ID']}"; logFileString($log_string); $this->forward("schedule/apf_schedule/list/" . $_POST['ID'] . "/ok/?y=" . $_REQUEST['y'] . "&m=" . $_REQUEST['m'] . "&d=" . $_REQUEST['d'] . ""); } else { $apf_schedule->setCreatedAt(DB_DataObject_Cast::dateTime()); $apf_schedule->insert(); $log_string = $i18n->_("Create") . $i18n->_("Schedule") . "\t{$_POST['title']}"; logFileString($log_string); $this->forward("schedule/apf_schedule/list/?y=" . $_REQUEST['y'] . "&m=" . $_REQUEST['m'] . "&d=" . $_REQUEST['d'] . ""); } } else { $template->setFile(array("MAIN" => "apf_schedule_list.html")); $template->setBlock("MAIN", "edit_block"); if ($_REQUEST['y'] && $_REQUEST['m'] && $_REQUEST['d']) { $select_y = $_REQUEST['y']; $select_m = $_REQUEST['m']; $select_d = $_REQUEST['d']; } else { $next_week_time = $this->getDefaultDate(); $select_y = date("Y", $next_week_time); $select_m = date("m", $next_week_time); $select_d = date("d", $next_week_time); } $used_hours_arr = array(); $CalDailyView = $this->renderDayView($select_y, $select_m, $select_d, $used_hours_arr); $un_use_hour_arr = array_diff($TimeOption, $used_hours_arr); array_shift($ActiveOption); $template->setVar(array("WEBDIR" => $WebBaseDir, "IMAGES_FILE" => fileTag('image', $_POST['upload_temp'] ? $_POST['upload_temp'] : $_POST['image_old']), "STATUS_FIELD" => selectTag('status', $ActiveOption, $_POST['status']), "LEFT_CALENDAR" => $this->renderMonthView(), "DAY_VIEW" => $CalDailyView, "PUBLISH_STARTTIME_OPTION" => selectTag('publish_starttime', $un_use_hour_arr, $_POST['publish_starttime']), "PUBLISH_ENDTIME_OPTION" => selectTag('publish_endtime', $un_use_hour_arr, $_POST['publish_endtime']), "DOACTION" => $do_action, "PUBLISH_DATE" => "{$select_y}-{$select_m}-{$select_d}", "Y" => $select_y, "M" => $select_m, "D" => $select_d)); if (is_array($val)) { foreach ($val as $k => $v) { if ($v == false) { $template->setVar(array(strtoupper($k) . "_ERROR_MSG" => " ↓ Please check here ↓ ")); } } } foreach ($val as $k => $v) { if ($v == false) { $template->setVar(array(strtoupper($k) . "_ERROR_MSG" => " ↓ " . $i18n->_("Please check here") . " ↓ ")); } } $template->setVar(array("ID" => $_POST['id'], "TITLE" => $_POST['title'], "DESCRIPTION" => $_POST['description'], "PUBLISH_DATE" => $_POST['publish_date'], "PUBLISH_STARTTIME" => $_POST['publish_starttime'], "PUBLISH_ENDTIME" => $_POST['publish_endtime'], "IMAGE" => $_POST['image'], "ACTIVE" => $_POST['active'], "ADD_IP" => $_POST['add_ip'], "CREATED_AT" => $_POST['created_at'], "UPDATE_AT" => $_POST['update_at'])); } }
function handleFormData($edit_submit = false) { global $template, $WebBaseDir, $i18n, $luadmin, $ClassDir, $AllowUploadFilesType, $UploadDir; include_once 'HTTP/UploadProgressMeter.class.php'; $fileWidget = new UploadProgressMeter(); $fileWidget->name = 'photo'; if ($fileWidget->uploadComplete()) { $fileWidget->finalStatus(); } $apf_users = DB_DataObject::factory('ApfUsers'); if ($edit_submit) { $apf_users->get($apf_users->escape($_POST['ID'])); $do_action = "updatesubmit"; } else { $do_action = "addsubmit"; } $apf_users->setUserName(stripslashes(trim($_POST['user_name']))); $apf_users->setRealname(stripslashes(trim($_POST['realname']))); $apf_users->setMemo(stripslashes(trim($_POST['memo']))); $apf_users->setGender(stripslashes(trim($_POST['gender']))); $apf_users->setAddrees(stripslashes(trim($_POST['addrees']))); $apf_users->setPhone(stripslashes(trim($_POST['phone']))); $apf_users->setEmail(stripslashes(trim($_POST['email']))); $apf_users->setRoleId(stripslashes(trim($_POST['role_id']))); $apf_users->setActive(stripslashes(trim($_POST['active']))); if ($_POST['photo_del'] == 'Y') { unlink($UploadDir . $_POST['photo_old']); $apf_users->setPhoto(""); $_POST['photo_old'] = ""; } if ($_POST['upload_temp']) { $apf_users->setPhoto($_POST['upload_temp']); } $allow_upload_file = TRUE; if ($_FILES['photo']['name']) { require_once $ClassDir . "FileHelper.class.php"; $upload_data = FileHelper::uploadFile("users"); $allow_upload_file = $upload_data["upload_state"]; if ($allow_upload_file) { $photos_arr = $upload_data["upload_msg"]; if ($photo_pic = $photos_arr['photo']) { $apf_users->setPhoto($photo_pic); $_POST['upload_temp'] = $photo_pic; } } else { $upload_error_msg = $upload_data["upload_msg"]; } } $val = $apf_users->validate(); if ($val === TRUE && $allow_upload_file === TRUE) { if ($edit_submit) { $apf_users->setUpdateAt(DB_DataObject_Cast::dateTime()); $apf_users->update(); $password = stripslashes(trim($_POST['user_pwd'])) ? stripslashes(trim($_POST['user_pwd'])) : stripslashes(trim($_POST['old_password'])); if (stripslashes(trim($_POST['user_pwd']))) { $data = array('handle' => stripslashes(trim($_POST['user_name'])), 'passwd' => $password); $updated = $luadmin->updateUser($data, $_POST['ID']); } //remove from group $filter = array('perm_user_id' => $_POST['ID'], 'group_id' => $_POST['old_group']); $luadmin->perm->removeUserFromGroup($filter); //add from group $data = array('perm_user_id' => $_POST['ID'], 'group_id' => $_POST['group']); $luadmin->perm->addUserToGroup($data); $this->forward("users/apf_users/update/" . $_POST['ID'] . "/ok"); } else { $data = array('handle' => stripslashes(trim($_POST['user_name'])), 'passwd' => stripslashes(trim($_POST['user_pwd'])), 'perm_type' => 1); $user_id = $luadmin->addUser($data); // add new group $data = array('perm_user_id' => $user_id, 'group_id' => $_POST['group']); $luadmin->perm->addUserToGroup($data); $apf_users->get($apf_users->escape($user_id)); // $apf_users->debugLevel(4); $apf_users->update(); $this->forward("users/apf_users/"); } } else { $template->setFile(array("MAIN" => "apf_users_edit.html")); $template->setBlock("MAIN", "edit_block"); $template->setVar(array("WEBDIR" => $WebBaseDir, "DOACTION" => $do_action)); foreach ($val as $k => $v) { if ($v == false) { $template->setVar(array(strtoupper($k) . "_ERROR_MSG" => " ↓ " . $i18n->_("Please check here") . " ↓ ")); } } if ($allow_upload_file !== TRUE) { $template->setVar(array("PHOTO_ERROR_MSG" => " ↓ {$upload_error_msg} ↓ ")); } $template->setVar(array("ID" => $_POST['id'], "USER_NAME" => $_POST['user_name'], "USER_PWD" => $_POST['user_pwd'], "GENDER" => $_POST['gender'], "ADDREES" => $_POST['addrees'], "PHONE" => $_POST['phone'], "EMAIL" => $_POST['email'], "PHOTO" => $_POST['photo'], "ROLE_ID" => $_POST['role_id'], "ACTIVE" => $_POST['active'], "ADD_IP" => $_POST['add_ip'], "CREATED_AT" => $_POST['created_at'], "UPDATE_AT" => $_POST['update_at'])); } }
function handleFormData($edit_submit = false) { global $template, $WebBaseDir, $i18n, $AddIP, $userid, $UploadDir, $ClassDir, $group_ids; $apf_selfproduct = DB_DataObject::factory('ApfSelfproduct'); if ($edit_submit) { $apf_selfproduct->get($apf_selfproduct->escape($_POST['ID'])); $do_action = "updatesubmit"; } else { $do_action = "addsubmit"; } $apf_selfproduct->setProductname(stripslashes(trim($_POST['productname']))); $apf_selfproduct->setRetailprice(stripslashes(trim($_POST['retailprice']))); $apf_selfproduct->setWholesaleprice(stripslashes(trim($_POST['wholesaleprice']))); $apf_selfproduct->setCostprice(stripslashes(trim($_POST['costprice']))); $apf_selfproduct->setReleasedate(stripslashes(trim($_POST['releasedate']))); $apf_selfproduct->setMemo(stripslashes(trim($_POST['memo']))); $apf_selfproduct->setAccess(stripslashes(trim($_POST['access']))); $apf_selfproduct->setActive(stripslashes(trim($_POST['active']))); $apf_selfproduct->setAddIp($AddIP); $apf_selfproduct->setGroupid($group_ids); $apf_selfproduct->setUserid($userid); if ($_POST['photo_del'] == 'Y') { unlink($UploadDir . $_POST['photo_old']); $apf_selfproduct->setPhoto(""); $_POST['photo_old'] = ""; } if ($_POST['upload_temp']) { $apf_selfproduct->setPhoto($_POST['upload_temp']); } $allow_upload_file = TRUE; if ($_FILES['photo']['name']) { require_once $ClassDir . "FileHelper.class.php"; $upload_data = FileHelper::uploadFile("product"); $allow_upload_file = $upload_data["upload_state"]; if ($allow_upload_file) { $photos_arr = $upload_data["upload_msg"]; if ($photo_pic = $photos_arr['photo']) { $apf_selfproduct->setPhoto($photo_pic); $_POST['upload_temp'] = $photo_pic; } } else { $upload_error_msg = $upload_data["upload_msg"]; } } $val = $apf_selfproduct->validate(); if ($val === TRUE && $allow_upload_file === TRUE) { if ($edit_submit) { $apf_selfproduct->setUpdateAt(DB_DataObject_Cast::dateTime()); $apf_selfproduct->update(); $log_string = $i18n->_("Update") . $i18n->_("ModuleName") . "\t{$_POST['name']}=>{$_POST['ID']}"; logFileString($log_string); $this->forward("selfproduct/apf_selfproduct/update/" . $_POST['ID'] . "/ok"); } else { $apf_selfproduct->setCreatedAt(DB_DataObject_Cast::dateTime()); $apf_selfproduct->insert(); $log_string = $i18n->_("Create") . $i18n->_("ModuleName") . "\t{$_POST['name']}=>{$_POST['create_date']}"; logFileString($log_string); $this->forward("selfproduct/apf_selfproduct/"); } } else { $template->setFile(array("MAIN" => "apf_selfproduct_edit.html")); $template->setBlock("MAIN", "edit_block"); $template->setVar(array("WEBDIR" => $WebBaseDir, "RELEASE_DATE" => inputDateTag("releasedate", $_POST['releasedate']), "FILEPHOTO" => fileTag("photo", $_POST['photo']), "MEMOTEXT" => textareaTag('memo', $_POST['memo'], false, "ROWS=\"8\" COLS=\"40\""), "DOACTION" => $do_action)); foreach ($val as $k => $v) { if ($v == false) { $template->setVar(array(strtoupper($k) . "_ERROR_MSG" => " ↓ " . $i18n->_("Please check here") . " ↓ ")); } } $template->setVar(array("ID" => $_POST['id'], "PRODUCTNAME" => $_POST['productname'], "RETAILPRICE" => $_POST['retailprice'], "WHOLESALEPRICE" => $_POST['wholesaleprice'], "COSTPRICE" => $_POST['costprice'], "PHOTO" => $_POST['photo'], "RELEASEDATE" => $_POST['releasedate'], "MEMO" => $_POST['memo'], "ACCESS" => $_POST['access'], "ACTIVE" => $_POST['active'], "GROUPID" => $_POST['groupid'], "USERID" => $_POST['userid'], "ADD_IP" => $_POST['add_ip'], "CREATED_AT" => $_POST['created_at'], "UPDATE_AT" => $_POST['update_at'])); } }