function doEditProductPrice() { global $CurrencyFormat; require_once 'I18N/Currency.php'; $args = func_get_args(); $price = $args[0]; $product_id = $args[1]; $company_id = $args[2]; $apf_product_price = DB_DataObject::factory('ApfProductPrice'); $apf_product_price->setCompanyId($company_id); $apf_product_price->setProductId($product_id); $apf_product_price->setPrice($price); $apf_product_price->setCreatedAt(DB_DataObject_Cast::dateTime()); $apf_product_price->insert(); $currency = new I18N_Currency($CurrencyFormat); return "<div ondblclick=\"editPrice('" . $product_id . "','" . $company_id . "','" . $price . "')\" >" . $currency->format($price) . "</div>"; }
function executeList($is_related = false) { global $template, $WebBaseDir, $WebTemplateDir, $ClassDir, $i18n, $WebUploadDir, $CurrencyFormat, $ActiveOption, $userid; include_once $ClassDir . "URLHelper.class.php"; require_once 'Pager/Pager.php'; require_once 'I18N/Currency.php'; $template->setFile(array("MAIN" => $is_related ? "apf_product_related_list.html" : "apf_product_list.html")); $template->setBlock("MAIN", "main_list", "list_block"); $currency = new I18N_Currency($CurrencyFormat); $category_arr = array("" => $i18n->_("All")) + $this->getCategory(); $max_row = 30; $apf_product = DB_DataObject::factory('ApfProduct'); $apf_product->orderBy('id desc'); if (($keyword = trim($_REQUEST['q'])) != "") { $apf_product->whereAdd("name LIKE '%" . $apf_product->escape("{$keyword}") . "%' "); } if (($category = trim($_REQUEST['category'])) != "") { $apf_product->whereAdd(" category = '" . $apf_product->escape("{$category}") . "' "); } if (($active = trim($_REQUEST['active'])) != "") { $apf_product->whereAdd(" active = '" . $apf_product->escape("{$active}") . "' "); } $apf_product->setUserid($userid); $ToltalNum = $apf_product->count(); $start_num = !isset($_GET['entrant']) ? 0 : ($_GET['entrant'] - 1) * $max_row; $apf_product->limit($start_num, $max_row); $apf_product->find(); $myData = array(); while ($apf_product->fetch()) { $myData[] = $apf_product->toArray(); } $params = array('totalItems' => $ToltalNum, 'perPage' => $max_row, 'delta' => 8, 'append' => true, 'separator' => ' | ', 'clearIfVoid' => false, 'urlVar' => 'entrant', 'useSessions' => true, 'closeSession' => true, 'prevImg' => $i18n->_("PrevPage"), 'nextImg' => $i18n->_("NextPage"), 'mode' => 'Jumping', 'extraVars' => array()); $pager =& Pager::factory($params); $links = $pager->getLinks(); $current_page = $pager->getCurrentPageID(); $selectBox = $pager->getPageSelectBox(array('autoSubmit' => true)); $i = 0; foreach ($myData as $data) { $i % 2 == 0 ? $list_td_class = "admin_row_0" : ($list_td_class = "admin_row_1"); $template->setVar(array("LIST_TD_CLASS" => $list_td_class)); $template->setVar(array("ID" => $data['id'], "CATEGORY" => $category_arr[$data['category']], "COMPANY_ID" => $data['company_id'], "NAME" => $data['name'], "PRICE" => $currency->format($data['price']), "PHOTO" => imageTag($data['photo']), "MEMO" => $data['memo'], "ACTIVE" => $ActiveOption[$data['active']], "ADD_IP" => $data['add_ip'], "CREATED_AT" => $data['created_at'], "UPDATE_AT" => $data['update_at'])); $template->parse("list_block", "main_list", TRUE); $i++; } $template->setVar(array("KEYWORD" => textTag("q", $_REQUEST['q']), "CATEGORYOPTION" => selectTag("category", $category_arr, $_REQUEST['category']), "ACTIVEOPTION" => selectTag("active", $ActiveOption, $_REQUEST['active']), "WEBDIR" => $WebBaseDir, "WEBTEMPLATEDIR" => URLHelper::getWebBaseURL() . $WebTemplateDir, "TOLTAL_NUM" => $ToltalNum, "CURRENT_PAGE" => $current_page, "SELECT_BOX" => $selectBox, "PAGINATION" => $links['all'])); }
function executeDetail() { global $template, $ModuleDir, $ClassDir, $WebTemplateDir, $WebBaseDir, $controller, $i18n, $ActiveOption, $WebTemplateFullPath, $GenderOption, $CurrencyFormat; include_once $ClassDir . "URLHelper.class.php"; require_once 'I18N/Currency.php'; require_once $ModuleDir . 'contact/ApfContact.class.php'; require_once $ModuleDir . 'product/ApfProduct.class.php'; $template->setFile(array("MAIN" => "apf_company_detail.html")); $template->setBlock("MAIN", "detail_block"); $apf_company = DB_DataObject::factory('Apfcompany'); $apf_company->get($apf_company->escape($controller->getID())); $template->setVar(array("ID" => $apf_company->getId(), "NAME" => $apf_company->getName(), "ADDREES" => $apf_company->getAddrees(), "PHONE" => $apf_company->getPhone(), "FAX" => $apf_company->getFax(), "EMAIL" => $apf_company->getEmail(), "PHOTO" => imageTag($apf_company->getPhoto()), "HOMEPAGE" => $apf_company->getHomepage(), "EMPLOYEE" => $apf_company->getEmployee(), "BANKROLL" => $apf_company->getBankroll(), "LINK_MAN" => $apf_company->getLinkMan(), "INCORPORATOR" => $apf_company->getIncorporator(), "INDUSTRY" => $apf_company->getIndustry(), "PRODUCTS" => $apf_company->getProducts(), "MEMO" => $apf_company->getMemo(), "ACTIVE" => $apf_company->getActive(), "ADD_IP" => $apf_company->getAddIp(), "CREATED_AT" => $apf_company->getCreatedAt(), "UPDATE_AT" => $apf_company->getUpdateAt())); // related contact $contact_category_arr = array("" => $i18n->_("All")) + ApfContact::getCategory(); $apf_company_contact = DB_DataObject::factory('ApfCompanyContact'); $apf_company_contact->whereAdd(" apf_company_contact.company_id = '" . $apf_company->getId() . "' "); $apf_company_contact->orderBy("apf_contact.id desc"); $apf_company_contact->buildContactJoin(); // $apf_company_contact->debugLevel(4); $apf_company_contact->find(); $template->setBlock("MAIN", "contact_list", "contact_list_block"); $i = 0; while ($apf_company_contact->fetch()) { $data = $apf_company_contact->toArray(); $i % 2 == 0 ? $list_td_class = "admin_row_0" : ($list_td_class = "admin_row_1"); $template->setVar(array("LIST_TD_CLASS" => $list_td_class)); // Var_Dump::display($data); $template->setVar(array("C_ID" => $data['id'], "C_CATEGORY" => $contact_category_arr[$data['category']], "C_NAME" => $data['name'], "C_GENDER" => $GenderOption[$data['gender']], "C_BIRTHDAY" => $data['birthday'], "C_ADDREES" => $data['addrees'], "C_OFFICE_PHONE" => $data['office_phone'], "C_PHONE" => $data['phone'], "C_FAX" => $data['fax'], "C_MOBILE" => $data['mobile'], "C_EMAIL" => $data['email'], "C_ACTIVE" => $data['active'])); $template->parse("contact_list_block", "contact_list", TRUE); $i++; } $contact_total = $i; // related product $currency = new I18N_Currency($CurrencyFormat); $product_category_arr = array("" => $i18n->_("All")) + ApfProduct::getCategory(); $apf_company_product = DB_DataObject::factory('ApfCompanyProduct'); $apf_company_product->orderBy("apf_product.id desc"); $apf_company_product->whereAdd(" apf_company_product.company_id = '" . $apf_company->getId() . "' "); $apf_company_product->buildProductJoin(); // $apf_company_product->debugLevel(4); $apf_company_product->find(); $template->setBlock("MAIN", "product_list", "product_list_block"); $i = 0; while ($apf_company_product->fetch()) { $data = $apf_company_product->toArray(); // get the last product price $apf_product_price = DB_DataObject::factory('ApfProductPrice'); $apf_product_price->whereAdd("company_id ='" . $apf_company->getId() . "' "); $apf_product_price->whereAdd("product_id ='{$data['id']}' "); $apf_product_price->orderBy('created_at desc'); // $apf_product_price->debugLevel(4); $apf_product_price->find(); $apf_product_price->fetch(); $data['price'] = $apf_product_price->getPrice() ? $apf_product_price->getPrice() : $data['price']; $i % 2 == 0 ? $list_td_class = "admin_row_0" : ($list_td_class = "admin_row_1"); $template->setVar(array("LIST_TD_CLASS" => $list_td_class)); // Var_Dump::display($data); $template->setVar(array("P_ID" => $data['id'], "P_CATEGORY" => $product_category_arr[$data['category']], "P_COMPANY_ID" => $data['company_id'], "P_NAME" => $data['name'], "P_PRICE" => "<div ondblclick=\"editPrice('" . $data['id'] . "','" . $apf_company->getId() . "','" . $data['price'] . "')\" >" . $currency->format($data['price']) . "</div>", "P_PHOTO" => imageTag($data['photo']), "P_MEMO" => $data['memo'], "P_ACTIVE" => $data['active'])); $template->parse("product_list_block", "product_list", TRUE); $i++; } $product_total = $i; $template->setVar(array("WEBDIR" => $WebBaseDir, "WEBTEMPLATEDIR" => URLHelper::getWebBaseURL() . $WebTemplateDir, "C_TOLTAL_NUM" => $contact_total, "P_TOLTAL_NUM" => $product_total, "WEBDIR" => $WebBaseDir, "COMID" => $apf_company->getId())); }
function executeList() { global $template, $controller, $WebBaseDir, $WebTemplateDir, $ClassDir, $CurrencyFormat; require_once 'I18N/Currency.php'; include_once $ClassDir . "URLHelper.class.php"; require_once 'Pager/Pager.php'; $template->setFile(array("MAIN" => "apf_product_price_list.html")); $template->setBlock("MAIN", "main_list", "list_block"); $currency = new I18N_Currency($CurrencyFormat); $apf_product_price = DB_DataObject::factory('ApfProductPrice'); if ($product_id = $controller->getURLParam(0)) { $apf_product_price->whereAdd("apf_product_price.product_id ='" . $apf_product_price->escape($product_id) . "' "); } if ($company_id = $controller->getURLParam(1)) { $apf_product_price->whereAdd("apf_product_price.company_id ='" . $apf_product_price->escape($company_id) . "' "); } $apf_product_price->orderBy('apf_product_price.id desc'); $apf_product_price->buildJoin(); $apf_product_price->selectAs(array("id", "price", "created_at"), 'p_%s'); $apf_product_price->selectAdd('apf_company.name AS company_name,apf_product.name AS product_name '); $max_row = 30; $ToltalNum = $apf_product_price->count(); $start_num = !isset($_GET['entrant']) ? 0 : ($_GET['entrant'] - 1) * $max_row; $apf_product_price->limit($start_num, $max_row); // $apf_product_price->debugLevel(4); $apf_product_price->find(); while ($apf_product_price->fetch()) { $myData[] = $apf_product_price->toArray(); } $params = array('totalItems' => $ToltalNum, 'perPage' => $max_row, 'delta' => 8, 'append' => true, 'separator' => ' | ', 'clearIfVoid' => false, 'urlVar' => 'entrant', 'useSessions' => true, 'closeSession' => true, 'prevImg' => $i18n->_("PrevPage"), 'nextImg' => $i18n->_("NextPage"), 'mode' => 'Jumping', 'extraVars' => array()); $pager =& Pager::factory($params); $links = $pager->getLinks(); $current_page = $pager->getCurrentPageID(); $selectBox = $pager->getPageSelectBox(array('autoSubmit' => true)); $i = 0; foreach ($myData as $data) { // Var_Dump::display($data); $i % 2 == 0 ? $list_td_class = "admin_row_0" : ($list_td_class = "admin_row_1"); $template->setVar(array("LIST_TD_CLASS" => $list_td_class)); $template->setVar(array("ID" => $data['p_id'], "COMPANY_ID" => $data['company_name'], "PRODUCT_ID" => $data['product_name'], "PRICE" => $currency->format($data['p_price']), "ADD_IP" => $data['add_ip'], "CREATED_AT" => $data['p_created_at'], "UPDATE_AT" => $data['update_at'])); $template->parse("list_block", "main_list", TRUE); $i++; } $template->setVar(array("WEBDIR" => $WebBaseDir, "WEBTEMPLATEDIR" => URLHelper::getWebBaseURL() . $WebTemplateDir, "TOLTAL_NUM" => $ToltalNum, "CURRENT_PAGE" => $current_page, "SELECT_BOX" => $selectBox, "PAGINATION" => $links['all'])); $controller->parseTemplateLang(); $template->parse("OUT", array("LAOUT")); $template->p("OUT"); exit; }
function executeList() { global $template, $WebBaseDir, $WebTemplateDir, $ClassDir, $CurrencyFormat, $DebitOption, $ActiveOption, $i18n, $userid; include_once $ClassDir . "URLHelper.class.php"; require_once 'Pager/Pager.php'; require_once 'I18N/Currency.php'; $currency = new I18N_Currency($CurrencyFormat); $category_arr = $this->getCategory(); $template->setFile(array("MAIN" => "apf_finance_list.html")); $template->setBlock("MAIN", "main_list", "list_block"); $apf_finance = DB_DataObject::factory('ApfFinance'); $order = $_GET['order'] ? $_GET['order'] : "DESC"; $orderfield = $_GET['orderfield'] ? $_GET['orderfield'] : "id"; $apf_finance->orderBy($apf_finance->escape($orderfield) . " " . $apf_finance->escape($order)); $apf_finance->setUserid($userid); $max_row = 30; $ToltalNum = $apf_finance->count(); $start_num = !isset($_GET['entrant']) ? 0 : ($_GET['entrant'] - 1) * $max_row; $apf_finance->limit($start_num, $max_row); $apf_finance->find(); $i = 0; $myData = array(); while ($apf_finance->fetch()) { $myData[] = $apf_finance->toArray(); $i++; } $params = array('totalItems' => $ToltalNum, 'perPage' => $max_row, 'delta' => 8, 'append' => true, 'separator' => ' | ', 'clearIfVoid' => false, 'urlVar' => 'entrant', 'useSessions' => true, 'closeSession' => true, 'prevImg' => $i18n->_("PrevPage"), 'nextImg' => $i18n->_("NextPage"), 'mode' => 'Jumping', 'extraVars' => array('order' => $_REQUEST['order'], 'orderfield' => $_REQUEST['orderfield'])); $pager =& Pager::factory($params); $links = $pager->getLinks(); $current_page = $pager->getCurrentPageID(); $selectBox = $pager->getPageSelectBox(array('autoSubmit' => true)); $page_exten = str_replace($pager->_url . "?", "", $pager->_getLinkTagUrl(null)); $id_header_url = showHeaderLink("id", $i18n->_("ID"), $_REQUEST['orderfield'], $_GET['order'], $page_exten, $pager->_url); $debit_header_url = showHeaderLink("debit", $i18n->_("Debit"), $_REQUEST['orderfield'], $_GET['order'], $page_exten, $pager->_url); $create_date_header_url = showHeaderLink("create_date", $i18n->_("CreateDate"), $_REQUEST['orderfield'], $_GET['order'], $page_exten, $pager->_url); $money_header_url = showHeaderLink("money", $i18n->_("Money"), $_REQUEST['orderfield'], $_GET['order'], $page_exten, $pager->_url); $i = 0; foreach ($myData as $data) { $i % 2 == 0 ? $list_td_class = "admin_row_0" : ($list_td_class = "admin_row_1"); $template->setVar(array("LIST_TD_CLASS" => $list_td_class)); $template->setVar(array("ID" => $data['id'], "CATEGORY" => $category_arr[$data['category']], "CREATE_DATE" => $data['create_date'], "AMOUNT" => $data['amount'], "DEBIT" => $DebitOption[$data['debit']], "MONEY" => $currency->format($data['money']), "MEMO" => $data['memo'], "ACTIVE" => $ActiveOption[$data['active']], "ADD_IP" => $data['add_ip'], "CREATED_AT" => $data['created_at'], "UPDATE_AT" => $data['update_at'])); $template->parse("list_block", "main_list", TRUE); $i++; } $template->setVar(array("WEBDIR" => $WebBaseDir, "WEBTEMPLATEDIR" => URLHelper::getWebBaseURL() . $WebTemplateDir, "TOLTAL_NUM" => $ToltalNum, "CURRENT_PAGE" => $current_page, "SELECT_BOX" => $selectBox, "ID_HEADER_URL" => $id_header_url, "DEBIT_HEADER_URL" => $debit_header_url, "CREATE_DATE_HEADER_URL" => $create_date_header_url, "MONEY_HEADER_URL" => $money_header_url, "PAGINATION" => $links['all'])); }