Exemple #1
0
 /**
  * grid
  * create the configuration of the grid
  */
 public static function grid($rowNum = 10)
 {
     $translator = Shineisp_Registry::getInstance()->Zend_Translate;
     $config['datagrid']['columns'][] = array('label' => null, 'field' => 'i.invoice_id', 'alias' => 'invoice_id', 'type' => 'selectall');
     $config['datagrid']['columns'][] = array('label' => $translator->translate('ID'), 'field' => 'i.invoice_id', 'alias' => 'invoice_id', 'sortable' => true, 'searchable' => true, 'type' => 'string', 'attributes' => array('width' => 50));
     $config['datagrid']['columns'][] = array('label' => $translator->translate('Invoice Number'), 'field' => 'i.formatted_number', 'alias' => 'formatted_number', 'sortable' => true, 'searchable' => true, 'type' => 'string');
     $config['datagrid']['columns'][] = array('label' => $translator->translate('Order Number'), 'field' => 'o.order_number', 'alias' => 'order_number', 'sortable' => true, 'searchable' => true, 'type' => 'string', 'attributes' => array('class' => 'hidden-xs hidden-sm'));
     $config['datagrid']['columns'][] = array('label' => $translator->translate('Date'), 'field' => 'i.invoice_date', 'alias' => 'invoice_date', 'sortable' => true, 'searchable' => true, 'type' => 'date', 'attributes' => array('class' => 'hidden-xs hidden-sm'));
     $config['datagrid']['columns'][] = array('label' => $translator->translate('Cost'), 'field' => 'o.cost', 'alias' => 'cost', 'sortable' => true, 'searchable' => true, 'type' => 'string', 'actions' => array('Invoices' => 'Total'), 'attributes' => array('class' => 'hidden-xs hidden-sm'));
     $config['datagrid']['columns'][] = array('label' => $translator->translate('Total'), 'field' => 'o.total', 'alias' => 'total', 'sortable' => true, 'searchable' => true, 'type' => 'string', 'actions' => array('Invoices' => 'Total'), 'attributes' => array('class' => 'hidden-xs hidden-sm'));
     $config['datagrid']['columns'][] = array('label' => $translator->translate('VAT'), 'field' => 'o.vat', 'alias' => 'vat', 'sortable' => true, 'searchable' => true, 'type' => 'string', 'actions' => array('Invoices' => 'Total'), 'attributes' => array('class' => 'hidden-xs hidden-sm'));
     $config['datagrid']['columns'][] = array('label' => $translator->translate('Grandtotal'), 'field' => 'o.grandtotal', 'alias' => 'grandtotal', 'sortable' => true, 'searchable' => true, 'type' => 'string', 'actions' => array('Invoices' => 'Total'), 'attributes' => array('class' => 'hidden-xs hidden-sm'));
     $config['datagrid']['columns'][] = array('label' => $translator->translate('Customer'), 'field' => "CONCAT(c.firstname,' ', c.lastname)", 'alias' => 'fullname', 'sortable' => true, 'searchable' => true, 'type' => 'string');
     $config['datagrid']['columns'][] = array('label' => $translator->translate('Company'), 'field' => "c.company", 'alias' => 'company', 'sortable' => true, 'searchable' => true, 'type' => 'string', 'attributes' => array('class' => 'hidden-xs hidden-sm'));
     #$config ['datagrid'] ['columns'] [] = array ('label' => $translator->translate ( 'Invoice dest.' ), 'field' => "CONCAT(r.firstname,' ', r.lastname)", 'alias' => 'invoice_dest', 'sortable' => true, 'type' => 'string', 'searchable' => true);
     $config['datagrid']['fields'] = "invoice_id, \n\t\t\t\t\t\t\t\t\t\t\tDATE_FORMAT(i.invoice_date, '" . Settings::getMySQLDateFormat('dateformat') . "') as invoice_date, \n\t\t\t\t\t\t\t\t\t\t\ti.formatted_number as formatted_number, \n\t\t\t\t\t\t\t\t\t\t\to.order_number as order_number, \n\t\t\t\t\t\t\t\t\t\t\to.cost as cost, \n\t\t\t\t\t\t\t\t\t\t\to.total as total, \n\t\t\t\t\t\t\t\t\t\t\to.vat as vat, \n\t\t\t\t\t\t\t\t\t\t\to.grandtotal as grandtotal, \n\t\t\t\t\t\t\t\t\t\t\tc.company as company,\n\t\t\t\t\t\t\t\t\t\t\tr.company as reseller,\n\t\t\t\t\t\t\t\t\t\t\tCONCAT(c.firstname,' ', c.lastname ) as fullname, \n\t\t\t\t\t\t\t\t\t\t\tCONCAT(r.firstname,' ', r.lastname ) ) as invoice_dest";
     $config['datagrid']['dqrecordset'] = Doctrine_Query::create()->select($config['datagrid']['fields'])->from('Invoices i')->leftJoin('i.Customers c')->leftJoin('c.Customers r')->leftJoin('i.Orders o')->orderBy('invoice_date desc');
     $config['datagrid']['rownum'] = $rowNum;
     $config['datagrid']['basepath'] = "/admin/invoices/";
     $config['datagrid']['index'] = "invoice_id";
     $config['datagrid']['rowlist'] = array('10', '50', '100', '1000');
     $config['datagrid']['buttons']['edit']['label'] = $translator->translate('Edit');
     $config['datagrid']['buttons']['edit']['cssicon'] = "edit";
     $config['datagrid']['buttons']['edit']['action'] = "/admin/invoices/edit/id/%d";
     $config['datagrid']['buttons']['delete']['label'] = $translator->translate('Delete');
     $config['datagrid']['buttons']['delete']['cssicon'] = "delete";
     $config['datagrid']['buttons']['delete']['action'] = "/admin/invoices/delete/id/%d";
     $config['datagrid']['massactions']['common'] = array('bulk_pdf_export' => 'Pdf List', 'bulk_csv_export' => 'Csv Export', 'bulk_print_invoices' => 'Download Invoices', 'bulk_delete_invoices' => 'Delete Invoices');
     if (Shineisp_Plugins_Dropbox_Main::isReady()) {
         $config['datagrid']['massactions']['common'] = array_merge($config['datagrid']['massactions']['common'], array('bulk_dropbox_invoices' => 'Upload Invoices into Dropbox Account'));
     }
     return $config;
 }
Exemple #2
0
 /**
  * Login in the dropbox account
  *
  * @return boolean
  * @throws Exception
  */
 protected static function login()
 {
     try {
         // get the authcode from the database
         $authcode = Settings::findbyParam('dropbox_authcode');
         $token = Settings::findbyParam('dropbox_token');
         if (!empty($token)) {
             self::$loggedIn = true;
             return true;
         }
         // if the authcode is set but the access token is not already set
         if (!empty($authcode)) {
             list($accessToken, $dropboxUserId) = self::$webAuth->finish($authcode);
             if ($accessToken) {
                 Settings::saveSetting('dropbox_token', $accessToken);
                 // save the
                 // token
                 self::$loggedIn = true;
                 return true;
             }
         }
         self::authorize();
         self::$loggedIn = false;
     } catch (Exception $e) {
         self::$loggedIn = false;
         Shineisp_Commons_Utilities::log(__METHOD__ . " " . $e->getMessage(), "plugin_dropbox.log");
     }
 }