public static function getCompanies() { $db = Core_Database::__getInstance(); $l = $db->select('companies', array('*')); $o = array(); foreach ($l as $v) { $i = count($o); $o[$i] = Profile_Company::getCompany($v['c_id']); $o[$i]->setData($v); } return $o; }
protected function getContent() { $action = Core_Tools::getInput('_GET', 'action', 'varchar'); $id = Core_Tools::getInput('_GET', 'id', 'int'); // Search for company: $objCompany = Profile_Company::getCompany($id); $login = Core_Login::__getInstance(); if ($action == 'add' && $login->isLogin()) { return $this->getAddCompany(); } elseif ($action == 'edit' && $login->isLogin() && $objCompany->isFound()) { return $this->getEditCompany($objCompany); } elseif ($action == 'shopman' && $objCompany->isFound()) { return $this->getShopManagement($objCompany); } elseif ($action == 'userman' && $objCompany->isFound()) { return $this->getUserManagement($objCompany); } elseif ($action == 'poefboek' && $objCompany->isFound()) { return $this->getPoefboekManagement($objCompany); } elseif ($action == 'poeflog' && $objCompany->isFound()) { return $this->getPoefboekLog($objCompany); } else { return $this->getCompanyOverview($objCompany); } }
private function getChooseCompany() { $text = Core_Text::__getInstance(); $text->setFile('account'); $text->setSection('company'); $myself = Profile_Member::getMyself(); $showForm = true; $companyId = Core_Tools::getInput('_POST', 'chooseCompany', 'int'); if ($companyId) { $company = Profile_Company::getCompany($companyId); if ($company->isFound()) { $company->addMember($myself); $showForm = false; header('Location: ' . self::getUrl('page=register')); return '<p>' . $text->get('done') . '</p>'; } } if ($showForm) { $page = new Core_Template(); $page->set('title', $text->get('title')); $page->set('about', $text->get('about')); $page->set('choose', $text->get('choose')); $page->set('noCompanies', $text->get('noCompanies')); $page->set('add', $text->getClickTo($text->get('toAddCompanie'))); $page->set('addUrl', self::getUrl('page=company&action=add')); $companies = Profile_Company::getCompanies(); foreach ($companies as $v) { $name = $v->getName(); if (!empty($name)) { $page->addListValue('companies', array($v->getName(), $v->getId())); } } $page->set('chooseComp', $text->get('chooseComp')); $page->set('submit', $text->get('submit')); $page->set('formAction', self::getUrl('page=register&action=companies')); return $page->parse('account_comp.tpl'); } }
public function getPendingOrders() { $db = Core_Database::__getInstance(); $l = $db->getDataFromQuery($db->customQuery("\n\t\t\tSELECT\n\t\t\t\t*\n\t\t\tFROM\n\t\t\t\torders o\n\t\t\tLEFT JOIN\n\t\t\t\torder_prods op ON o.o_id = op.o_id\n\t\t\tWHERE\n\t\t\t\top.plid = '" . (int) $this->getId() . "'\n\t\t\t\tAND o.o_isDone = '0'\n\t\t")); $o = array(); foreach ($l as $v) { $shop = Profile_Shop::getShop($v['s_id']); $company = Profile_Company::getCompany($v['c_id']); $o[] = array($shop->getProduct($v['p_id']), $v, $company, $shop); } return $o; }
private function doCron() { $db = Core_Database::__getInstance(); $hour = date('H'); $day = date('w'); if ($day > 0 && $day < 6) { // Select all companies $companies = $db->select('companies', array('*'), "c_hour = " . intval($hour)); echo '<pre>'; echo 'It\'s ' . $hour . 'h, time for reminders!' . "\n"; $count = 0; foreach ($companies as $v) { $company = Profile_Company::getCompany($v['c_id']); echo 'Sending mails to ' . $company->getName() . ".\n"; $company->sendReminders(); $count++; } if ($count == 0) { echo 'No reminders were sent.'; } echo '</pre>'; } else { echo '<pre>It\'s weekend.</pre>'; } }
public function getAddShop() { $login = Core_Login::__getInstance(); $db = Core_Database::__getInstance(); $text = Core_Text::__getInstance(); $text->setFile('shop'); $text->setSection('addShop'); if ($login->isLogin()) { $page = new Core_Template(); $page->set('title', $text->get('title')); $page->set('about', $text->get('about')); $showform = true; // Check for input $shop = Core_Tools::getInput('_POST', 'shop', 'varchar'); $adres = Core_Tools::getInput('_POST', 'adres', 'varchar'); $postcode = Core_Tools::getInput('_POST', 'postcode', 'varchar'); $gemeente = Core_Tools::getInput('_POST', 'gemeente', 'varchar'); $email = Core_Tools::getInput('_POST', 'email', 'varchar'); // Company id $cid = Core_Tools::getInput('_GET', 'cid', 'int'); if ($shop) { // Let's add the shop $sid = $db->insert('shops', array('s_name' => $shop, 's_adres' => $adres, 's_postcode' => $postcode, 's_gemeente' => $gemeente, 's_email' => $email)); // Add you as a moderator $db->insert('players_shop', array('plid' => $login->getUserId(), 's_id' => $sid)); // Now let's add the company (if set) $company = Profile_Company::getCompany($cid); $myself = Profile_Member::getMyself(); if ($cid > 0 && $company->isFound() && $myself && ($company->getUserStatus($myself) == 'moderator' || $company->getUserStatus($myself) == 'administrator')) { $showform = false; $company->addShop($sid); header('Location: ' . self::getUrl('page=shop&id=' . $sid . '&action=manage')); } return '<p>' . $text->get('done') . '</p>'; } elseif ($shop || $adres || $postcode || $gemeente || $email) { $warning = $text->get('completeForm'); } if ($showform) { $page = new Core_Template(); if (isset($warning)) { $page->set('warning', $warning); } $page->set('shop_value', Core_Tools::output_form($shop)); $page->set('adres_value', Core_Tools::output_form($adres)); $page->set('postcode_value', Core_Tools::output_form($postcode)); $page->set('gemeente_value', Core_Tools::output_form($gemeente)); $page->set('email_value', Core_Tools::output_form($email)); $page->set('title', $text->get('title')); $page->set('about', $text->get('about')); $page->set('submit', $text->get('submit')); $page->set('shop', $text->get('shop')); $page->set('adres', $text->get('adres')); $page->set('postcode', $text->get('postcode')); $page->set('gemeente', $text->get('gemeente')); $page->set('email', $text->get('email')); $page->set('formAction', self::getUrl('page=shop&action=add&cid=' . $cid)); } return $page->parse('shop_add.tpl'); } else { return '<p>' . $text->get('noLogin') . '</p>'; } }
private function getOrderOverview($order, $showOnlineVersion = true, $showSended = false, $showNames = true) { $db = Core_Database::__getInstance(); $text = Core_Text::__getInstance(); $text->setFile('order'); $text->setSection('submit'); $page = new Core_Template(); $company = Profile_Company::getCompany($order['c_id']); $company->setData($order); $shop = Profile_Shop::getShop($order['s_id']); $page->set('company', $text->get('company')); $page->set('shop', $text->get('shop')); $page->set('listProducts', $text->get('listProducts')); $page->set('orderId', $order['o_id']); $page->set('company_adres', $company->getAdress()); $page->set('shop_adres', $shop->getAdress()); $page->set('currency', Core_Tools::output_varchar($shop->getCurrency())); $page->set('date', new DateTime($order['o_orderDate'])); $page->set('thanks', $text->get('thanks')); if ($showOnlineVersion && $order['o_isDone'] == 1) { $page->set('sendMail', $text->get('sendMail')); $page->set('email', $text->get('email')); $page->set('sendIt', $text->get('sendIt')); $page->set('printIt', $text->get('printIt')); if ($showSended) { $page->set('sended', $text->get('sended')); } $page->set('mail_action', Pages_Page::getUrl('page=order&oid=' . $order['o_id'])); } $products = $this->getOrderedProducts($order['o_id']); $page->set('table_cols', $showOnlineVersion ? 3 : 2); // Fetch the categories for this shop $categories = $shop->getCategories(); foreach ($products as $v) { if ($v['op_amount'] > 1) { $name = $v['op_amount'] . ' x ' . Core_Tools::output_varchar($v['p_name']); } else { $name = Core_Tools::output_varchar($v['p_name']); } // Fetch price name $catname = ''; if (isset($categories[$v['c_id']]) && count($categories[$v['c_id']]['prices']) > 1) { if (isset($categories[$v['c_id']]['prices'][$v['p_pid']])) { $catname = ' (' . $categories[$v['c_id']]['prices'][$v['p_pid']]['c_name'] . ')'; } } $page->addListValue('products', array($name, $showNames ? Core_Tools::output_varchar($v['realname']) : null, Core_Tools::convert_price($v['op_amount'] * $v['op_price']), $v['op_message'], $catname)); } return $page->parse('order_view.tpl'); }