Ejemplo n.º 1
0
 /**
  * export the content in a pdf file
  * @param array $items
  */
 public function bulk_export($items)
 {
     $isp = Isp::getCurrentId();
     $pdf = new Shineisp_Commons_PdfList();
     $translator = Shineisp_Registry::getInstance()->Zend_Translate;
     // Get the records from the order table
     $orders = self::get_orders($items, "order_id, i.number as invoicenum, DATE_FORMAT(order_date, '" . Settings::getMySQLDateFormat('dateformat') . "') as orderdate, c.company as company, CONCAT(c.firstname, ' ', c.lastname) as fullname, total as total, vat as vat, grandtotal as grandtotal, s.status as status", 'order_date');
     // Create the PDF header
     $grid['headers']['title'] = $translator->translate('Orders List');
     $grid['headers']['subtitle'] = $translator->translate('Order Listing');
     $grid['footer']['text'] = $isp['company'] . " - " . $isp['website'];
     if (!empty($orders[0])) {
         // Create the columns of the grid
         $grid['columns'][] = array("value" => $translator->translate('Order'), 'size' => 50);
     }
     $grid['columns'][] = array("value" => $translator->translate('Invoice'), 'size' => 50);
     $grid['columns'][] = array("value" => $translator->translate('Date'), 'size' => 100);
     $grid['columns'][] = array("value" => $translator->translate('Company'));
     $grid['columns'][] = array("value" => $translator->translate('Fullname'));
     $grid['columns'][] = array("value" => $translator->translate('Total'), 'size' => 50);
     $grid['columns'][] = array("value" => $translator->translate('VAT'), 'size' => 50);
     $grid['columns'][] = array("value" => $translator->translate('Grand Total'), 'size' => 50);
     $grid['columns'][] = array("value" => $translator->translate('Status'), 'size' => 100);
     // Getting the records values and delete the first column the customer_id field.
     foreach ($orders as $item) {
         $values = array_values($item);
         $grid['records'][] = $values;
     }
     // Create the PDF
     die($pdf->create($grid));
     return false;
 }
Ejemplo n.º 2
0
 /**
  * Get a customer by id lists
  * @param array $ids [1,2,3,4,...,n]
  * @param string $fields
  * @return Array
  */
 public static function get_products($ids = array(), $fields = null, $locale = 1)
 {
     $dq = Doctrine_Query::create()->from('Products p')->leftJoin('p.ProductsAttributesGroups pag')->leftJoin("p.ProductsData pd WITH pd.language_id = {$locale}")->leftJoin('p.Taxes t')->leftJoin('p.ProductsAttributesIndexes pai')->leftJoin('p.ProductsTranches pt')->leftJoin('p.ProductsMedia pm')->leftJoin('pt.BillingCycle bc')->andWhere("isp_id = ?", Isp::getCurrentId());
     if (!empty($fields)) {
         $dq->select($fields);
     }
     if (!empty($ids)) {
         $dq->whereIn("product_id", $ids);
     }
     return $dq->execute(array(), Doctrine::HYDRATE_ARRAY);
 }
Ejemplo n.º 3
0
 /**
  * massdelete
  * delete the customer selected 
  * @param array
  * @return Boolean
  */
 public static function bulk_delete($customers)
 {
     $retval = Doctrine_Query::create()->delete()->from('Customers c')->whereIn('c.customer_id', $customers)->addWhere("c.isp_id = ?", Isp::getCurrentId())->execute();
     foreach ($customers as $customerid) {
         CustomersDomainsRegistrars::del($customerid);
         Orders::DeleteByCustomerID($customerid);
         Shineisp_Commons_Utilities::delTree(PUBLIC_PATH . "/documents/orders/{$customerid}");
         // Delete the orders files
     }
     return $retval;
 }
Ejemplo n.º 4
0
 /**
  * Get the complete category menu
  * 
  */
 public static function getMenu()
 {
     $isp_id = Isp::getCurrentId();
     $categories = array();
     $dq = Doctrine_Query::create()->select('c.category_id as id, c.name, c.parent, c.uri, c.description, c.keywords')->from('ProductsCategories c')->where('c.enabled = ?', 1)->andWhere('c.show_in_menu = ?', 1)->andWhere('c.isp_id = ?', $isp_id)->orderBy('c.parent, c.position, c.name');
     $dq->addSelect('( SELECT COUNT( * ) FROM ProductsCategories pc WHERE pc.parent = c.category_id) as children');
     $records = $dq->execute(array(), Doctrine_Core::HYDRATE_ARRAY);
     if (!empty($records)) {
         foreach ($records as $category) {
             $total = self::countProducts($category['id']);
             if ($total) {
                 $categories[] = $category;
             }
         }
     }
     return $categories;
 }
Ejemplo n.º 5
0
 /**
  * Summary of all the domain stautus
  * @return array
  */
 public static function summary()
 {
     $translator = Shineisp_Registry::getInstance()->Zend_Translate;
     $dq = Doctrine_Query::create()->select("domain_id, count(*) as items, s.status as status")->from('Domains d')->leftJoin('d.Statuses s')->leftJoin('d.Customers c')->where("s.section = 'domains'")->addWhere("c.isp_id = ?", Isp::getCurrentId())->groupBy('s.status');
     $records = $dq->execute(array(), Doctrine_Core::HYDRATE_ARRAY);
     $records['data'] = $records;
     $records['fields'] = array('items' => array('label' => $translator->translate('Items')), 'status' => array('label' => $translator->translate('Status')));
     return $records;
 }
Ejemplo n.º 6
0
 /**
  * Get the related products starting 
  * by a specific product_id
  * excluding itself
  * 
  * @param integer $product_id
  */
 public static function get_products($product_id, $locale = "1")
 {
     $related = Doctrine_Query::create()->select("pr.related_id, p.product_id as product_id, p.uri as uri, p.price_1 as price, pd.name as name, pd.shortdescription as description, p.ishighlighted as ishighlighted")->from('ProductsRelated pr')->leftJoin('pr.Products p')->leftJoin("p.ProductsData pd WITH pd.language_id = {$locale}")->where('pr.product_id = ?', $product_id)->addWhere("p.product_id <> ?", $product_id)->addWhere("p.isp_id = ?", Isp::getCurrentId())->orderBy('p.group_id, p.position')->execute(array(), Doctrine_Core::HYDRATE_ARRAY);
     return $related;
 }
Ejemplo n.º 7
0
 /**
  * Get the product sold summary or per year
  */
 public static function getBestseller($year = null)
 {
     $Session = new Zend_Session_Namespace('Admin');
     $locale = $Session->langid;
     // Get the year incomes total and subtract the credit memo
     $dq = Doctrine_Query::create()->select('detail_id, p.product_id as id, count(*) as total,  pag.name as group, pd.name as product,')->from('OrdersItems oi')->leftJoin('oi.Orders o')->leftJoin('oi.Products p')->leftJoin("p.ProductsData pd WITH pd.language_id = {$locale}")->leftJoin('p.ProductsAttributesGroups pag')->where('oi.status_id = ? OR oi.status_id = ?', array(Statuses::id('paid', 'orders'), Statuses::id('complete', 'orders')))->andWhere('p.isp_id = ?', Isp::getCurrentId())->groupBy('pd.name')->orderBy('count(*) desc');
     if (is_numeric($year)) {
         $dq->andWhere('Year(o.order_date) = ?', $year);
     }
     $data = $dq->execute(null, Doctrine::HYDRATE_ARRAY);
     return $data;
 }
Ejemplo n.º 8
0
 /**
  * Get a tickets by id lists
  * @param array $ids [1,2,3,4,...,n]
  * @param string $fields
  * @return Array
  */
 public static function get_tickets($ids, $fields = null)
 {
     $dq = Doctrine_Query::create()->from('Tickets t')->leftJoin('t.Customers c')->leftJoin('t.TicketsCategories tc')->leftJoin('t.Domains d')->leftJoin('d.DomainsTlds dt')->leftJoin('dt.WhoisServers ws')->leftJoin('t.Statuses s')->leftJoin('t.Tickets t2')->whereIn("ticket_id", $ids)->addWhere("c.isp_id = ?", Isp::getCurrentId());
     if (!empty($fields)) {
         $dq->select($fields);
     }
     return $dq->execute(array(), Doctrine::HYDRATE_ARRAY);
 }
Ejemplo n.º 9
0
 /**
  * Get the list of the AdminUser saved
  *
  * @return ArrayObject
  */
 public static function getList()
 {
     $items = array();
     $arrTypes = Doctrine::getTable('AdminUser')->findAll();
     foreach ($arrTypes->getData() as $c) {
         if ($c['isp_id'] != Isp::getCurrentId()) {
             continue;
         }
         $items[$c['user_id']] = $c['lastname'] . " " . $c['firstname'];
     }
     return $items;
 }