Exemplo n.º 1
0
 public function indexAction()
 {
     $toolbar = new Statistics_Form_Toolbar();
     $options = $this->_helper->Options->getOptions($toolbar, $this->_user['clientid']);
     $params = $this->_helper->Params->getParams($toolbar, $options);
     $charts = new Statistics_Model_Charts();
     $charts->createCharts(13, 500, 300, $this->view->translate('STATISTICS_UNCATEGORIZED'), $params, $options);
     $quotesDb = new Sales_Model_DbTable_Quote();
     $quotes = $quotesDb->fetchAll($quotesDb->select()->where('quoteid = ?', 0)->order('id desc')->limit(5));
     $this->view->quotes = $quotes;
     $salesordersDb = new Sales_Model_DbTable_Salesorder();
     $salesorders = $salesordersDb->fetchAll($salesordersDb->select()->where('salesorderid = ?', 0)->order('id desc')->limit(5));
     $this->view->salesorders = $salesorders;
     $invoicesDb = new Sales_Model_DbTable_Invoice();
     $invoices = $invoicesDb->fetchAll($invoicesDb->select()->where('invoiceid = ?', 0)->order('id desc')->limit(5));
     $this->view->invoices = $invoices;
     $quoterequestsDb = new Purchases_Model_DbTable_Quoterequest();
     $quoterequests = $quoterequestsDb->fetchAll($quoterequestsDb->select()->where('quoterequestid = ?', 0)->order('id desc')->limit(5));
     $this->view->quoterequests = $quoterequests;
     $purchaseordersDb = new Purchases_Model_DbTable_Purchaseorder();
     $purchaseorders = $purchaseordersDb->fetchAll($purchaseordersDb->select()->where('purchaseorderid = ?', 0)->order('id desc')->limit(5));
     $this->view->purchaseorders = $purchaseorders;
     $this->view->options = $options;
     $this->view->toolbar = new Application_Form_Toolbar();
     $this->view->messages = $this->_flashMessenger->getMessages();
 }
Exemplo n.º 2
0
 public function createCharts($lenght, $width = 1000, $height = 400, $statisticsUncategorized, $params, $options)
 {
     //print_r($params);
     //print_r($options);
     $year = date('Y');
     $month = date('m');
     $y = date('Y', strtotime('-' . ($lenght - 1) . ' month'));
     $m = date('m', strtotime('-' . ($lenght - 1) . ' month'));
     $user = Zend_Registry::get('User');
     $invoicesDb = new Sales_Model_DbTable_Invoice();
     $creditnotesDb = new Sales_Model_DbTable_Creditnote();
     $turnover = array();
     $turnoverCategories = array();
     while ($y <= $year) {
         while ($m) {
             if ($y < $year || $m <= $month) {
                 //Get invoices
                 $ym = str_pad($m, 2, '0', STR_PAD_LEFT);
                 $query = 'i.state = 105';
                 $query .= " AND (invoicedate BETWEEN '" . $y . "-" . $ym . "-" . "01' AND '" . $y . "-" . $ym . "-" . "31')";
                 $query .= ' AND i.clientid = ' . $user['clientid'];
                 $query .= ' AND c.clientid = ' . $user['clientid'];
                 if ($params['catid']) {
                     $query = Zend_Controller_Action_HelperBroker::getStaticHelper('Query')->getQueryCategory($query, $params['catid'], $options['categories'], 'c');
                 }
                 if ($params['country']) {
                     $query = Zend_Controller_Action_HelperBroker::getStaticHelper('Query')->getQueryCountry($query, $params['country'], 'i');
                 }
                 $invoices = $invoicesDb->fetchAll($invoicesDb->select()->from(array('i' => 'invoice'))->join(array('c' => 'contact'), 'i.contactid = c.id', array('catid'))->where($query ? $query : 1)->setIntegrityCheck(false));
                 //Get credit notes
                 $ym = str_pad($m, 2, '0', STR_PAD_LEFT);
                 $query = 'i.state = 105';
                 $query .= " AND (creditnotedate BETWEEN '" . $y . "-" . $ym . "-" . "01' AND '" . $y . "-" . $ym . "-" . "31')";
                 $query .= ' AND i.clientid = ' . $user['clientid'];
                 $query .= ' AND c.clientid = ' . $user['clientid'];
                 if ($params['catid']) {
                     $query = Zend_Controller_Action_HelperBroker::getStaticHelper('Query')->getQueryCategory($query, $params['catid'], $options['categories'], 'c');
                 }
                 if ($params['country']) {
                     $query = Zend_Controller_Action_HelperBroker::getStaticHelper('Query')->getQueryCountry($query, $params['country'], 'i');
                 }
                 $creditnotes = $creditnotesDb->fetchAll($creditnotesDb->select()->from(array('i' => 'creditnote'))->join(array('c' => 'contact'), 'i.contactid = c.id', array('catid'))->where($query ? $query : 1)->setIntegrityCheck(false));
                 $turnover[$y . $ym] = 0;
                 $turnoverCategories[0][$y . $ym] = 0;
                 //Calculate invoices
                 foreach ($invoices as $invoice) {
                     $turnover[$y . $ym] += $invoice->subtotal;
                     if (isset($turnoverCategories[$invoice->catid][$y . $ym])) {
                         $turnoverCategories[$invoice->catid][$y . $ym] += $invoice->subtotal;
                     } else {
                         $turnoverCategories[$invoice->catid][$y . $ym] = $invoice->subtotal;
                     }
                 }
                 //Calculate credit notes
                 foreach ($creditnotes as $creditnote) {
                     $turnover[$y . $ym] -= $creditnote->subtotal;
                     if (isset($turnoverCategories[$creditnote->catid][$y . $ym])) {
                         $turnoverCategories[$creditnote->catid][$y . $ym] += $creditnote->subtotal;
                     } else {
                         $turnoverCategories[$creditnote->catid][$y . $ym] = $creditnote->subtotal;
                     }
                 }
                 //Calculate categories
                 foreach ($options['categories'] as $id => $category) {
                     if (isset($turnoverCategories[$id][$y . $ym])) {
                         $turnoverCategories[$id][$y . $ym] = round($turnoverCategories[$id][$y . $ym]);
                     } else {
                         $turnoverCategories[$id][$y . $ym] = 0;
                     }
                 }
                 $turnover[$y . $ym] = round($turnover[$y . $ym]);
                 $turnoverCategories[0][$y . $ym] = round($turnoverCategories[0][$y . $ym]);
                 $dataDb = 'total:' . $turnover[$y . $ym] . ';';
                 foreach ($turnoverCategories as $key => $value) {
                     if (isset($value[$y . $ym])) {
                         $dataDb .= $key . ':' . $value[$y . $ym] . ';';
                     }
                 }
                 //$archiveDb->addArchive($y.$ym, $dataDb, $user['clientid']);
                 $months[$y . $ym] = $y . '/' . $ym;
             }
             ++$m;
             if ($m > 12) {
                 $m = 0;
             }
         }
         ++$y;
         $m = 1;
     }
     //Merge subcategories to main categories
     foreach ($turnoverCategories as $id => $values) {
         if (isset($options['categories'][$id]['childs']) && $id != $params['catid']) {
             foreach ($options['categories'][$id]['childs'] as $childId) {
                 foreach ($values as $month => $value) {
                     $turnoverCategories[$id][$month] += $turnoverCategories[$childId][$month];
                 }
                 unset($turnoverCategories[$childId]);
             }
         }
     }
     //Remove empty arrays
     foreach ($turnoverCategories as $key => $values) {
         if (!array_sum($values)) {
             unset($turnoverCategories[$key]);
         }
     }
     require_once BASE_PATH . '/library/pChart/class/pData.class.php';
     require_once BASE_PATH . '/library/pChart/class/pDraw.class.php';
     require_once BASE_PATH . '/library/pChart/class/pImage.class.php';
     //Turnover
     /* Create your dataset object */
     $turnoverData = new pData();
     /* Add data in your dataset */
     $turnoverData->addPoints($turnover, 'Values');
     $turnoverData->setAxisName(0, '€ / Netto');
     /* Create the X serie */
     $turnoverData->addPoints($months, 'Labels');
     $turnoverData->setSerieDescription('Labels', 'Months');
     $turnoverData->setAbscissa('Labels');
     /* Create a pChart object and associate your dataset */
     $turnover = new pImage($width, $height, $turnoverData);
     /* Turn off AA processing */
     $turnover->Antialias = FALSE;
     /* Choose a nice font */
     $turnover->setFontProperties(array('FontName' => BASE_PATH . '/library/pChart/fonts/verdana.ttf', 'FontSize' => 10));
     /* Define the boundaries of the graph area */
     $turnover->setGraphArea(75, 20, $width - 30, $height - 60);
     /* Draw the scale, keep everything automatic */
     $turnover->drawScale(array('DrawSubTicks' => TRUE, 'Mode' => SCALE_MODE_START0, 'LabelRotation' => 45));
     /* Draw the scale, keep everything automatic */
     $settings = array('Gradient' => TRUE, 'GradientMode' => GRADIENT_EFFECT_CAN, 'DisplayPos' => LABEL_POS_INSIDE, 'DisplayValues' => TRUE, 'DisplayR' => 0, 'DisplayG' => 0, 'DisplayB' => 0, 'DisplayShadow' => TRUE, 'Surrounding' => 10);
     $turnover->drawBarChart($settings);
     /* Build the PNG file and send it to the web browser */
     if (!file_exists(BASE_PATH . '/cache/chart/')) {
         mkdir(BASE_PATH . '/cache/chart/');
         chmod(BASE_PATH . '/cache/chart/', 0777);
     }
     $turnover->Render(BASE_PATH . '/cache/chart/turnover-' . $width . '-' . $height . '.png');
     //Turnover by categories
     /* Create your dataset object */
     $turnoverCategoriesData = new pData();
     /* Add data in your dataset */
     $turnoverCategoriesTotal = array();
     foreach ($turnoverCategories as $key => $value) {
         $turnoverCategoriesTotal[$key] = array_sum($value);
     }
     arsort($turnoverCategoriesTotal);
     foreach ($turnoverCategoriesTotal as $key => $value) {
         if ($key && isset($options['categories'][$key])) {
             $turnoverCategoriesData->addPoints($turnoverCategories[$key], $options['categories'][$key]['title']);
         }
     }
     if (isset($turnoverCategories[0])) {
         $turnoverCategoriesData->addPoints($turnoverCategories[0], $statisticsUncategorized);
     }
     $turnoverCategoriesData->setAxisName(0, '€ / Netto');
     /* Create the X serie */
     $turnoverCategoriesData->addPoints($months, 'Labels');
     $turnoverCategoriesData->setSerieDescription('Labels', 'Months');
     $turnoverCategoriesData->setAbscissa('Labels');
     /* Create a pChart object and associate your dataset */
     $turnoverCategories = new pImage($width, $height, $turnoverCategoriesData);
     /* Turn off AA processing */
     $turnoverCategories->Antialias = FALSE;
     /* Choose a nice font */
     $turnoverCategories->setFontProperties(array('FontName' => BASE_PATH . '/library/pChart/fonts/verdana.ttf', 'FontSize' => 10));
     /* Define the boundaries of the graph area */
     $turnoverCategories->setGraphArea(75, 20, $width - 30, $height - 60);
     /* Draw the scale, keep everything automatic */
     $turnoverCategories->drawScale(array('XMargin' => 2, 'DrawSubTicks' => TRUE, 'Mode' => SCALE_MODE_ADDALL_START0, 'LabelRotation' => 45));
     /* Draw the scale, keep everything automatic */
     $settings = array();
     $turnoverCategories->drawStackedAreaChart($settings);
     /* Write the chart legend */
     $turnoverCategories->drawLegend(100, 20, array('Style' => LEGEND_NOBORDER, 'Mode' => LEGEND_VERTICAL));
     /* Build the PNG file and send it to the web browser */
     $turnoverCategories->Render(BASE_PATH . '/cache/chart/turnover-category-' . $width . '-' . $height . '.png');
 }
Exemplo n.º 3
0
 protected function search($params, $categories)
 {
     $invoicesDb = new Sales_Model_DbTable_Invoice();
     $columns = array('i.title', 'i.invoiceid', 'i.contactid', 'i.billingname1', 'i.billingname2', 'i.billingdepartment', 'i.billingstreet', 'i.billingpostcode', 'i.billingcity', 'i.shippingname1', 'i.shippingname2', 'i.shippingdepartment', 'i.shippingstreet', 'i.shippingpostcode', 'i.shippingcity');
     $query = '';
     $schema = 'i';
     if ($params['keyword']) {
         $query = $this->_helper->Query->getQueryKeyword($query, $params['keyword'], $columns);
     }
     if ($params['catid']) {
         $query = $this->_helper->Query->getQueryCategory($query, $params['catid'], $categories, 'c');
     }
     if ($params['states']) {
         $query = $this->_helper->Query->getQueryStates($query, $params['states'], $schema);
     }
     if ($params['daterange']) {
         $query = $this->_helper->Query->getQueryDaterange($query, $params['from'], $params['to'], $schema);
     }
     if ($params['country']) {
         $query = $this->_helper->Query->getQueryCountry($query, $params['country'], $schema);
     }
     if ($params['catid']) {
         $invoices = $invoicesDb->fetchAll($invoicesDb->select()->setIntegrityCheck(false)->from(array($schema => 'invoice'))->join(array('c' => 'contact'), $schema . '.contactid = c.id', array('catid'))->group($schema . '.id')->where($query ? $query : 1)->order($params['order'] . ' ' . $params['sort'])->limit($params['limit']));
         if (!count($invoices) && $params['keyword']) {
             $this->_flashMessenger->addMessage('MESSAGES_SEARCH_RETURNED_NO_RESULTS');
             $query = $this->_helper->Query->getQueryKeyword('', $params['keyword'], $columns);
             $invoices = $invoicesDb->fetchAll($invoicesDb->select()->setIntegrityCheck(false)->from(array($schema => 'invoice'))->join(array('c' => 'contact'), $schema . '.contactid = c.id', array('catid'))->group($schema . '.id')->where($query ? $query : 1)->order($params['order'] . ' ' . $params['sort'])->limit($params['limit']));
         }
     } else {
         $invoices = $invoicesDb->fetchAll($invoicesDb->select()->setIntegrityCheck(false)->from(array($schema => 'invoice'))->group($schema . '.id')->where($query ? $query : 1)->order($params['order'] . ' ' . $params['sort'])->limit($params['limit']));
         if (!count($invoices) && $params['keyword']) {
             $this->_flashMessenger->addMessage('MESSAGES_SEARCH_RETURNED_NO_RESULTS');
             $query = $this->_helper->Query->getQueryKeyword('', $params['keyword'], $columns);
             $invoices = $invoicesDb->fetchAll($invoicesDb->select()->setIntegrityCheck(false)->from(array($schema => 'invoice'))->group($schema . '.id')->where($query ? $query : 1)->order($params['order'] . ' ' . $params['sort'])->limit($params['limit']));
         }
     }
     $invoices->subtotal = 0;
     $invoices->total = 0;
     foreach ($invoices as $invoice) {
         $invoices->subtotal += $invoice->subtotal;
         $invoices->total += $invoice->total;
         $invoice->subtotal = $this->_currency->toCurrency($invoice->subtotal);
         $invoice->taxes = $this->_currency->toCurrency($invoice->taxes);
         $invoice->total = $this->_currency->toCurrency($invoice->total);
     }
     $invoices->subtotal = $this->_currency->toCurrency($invoices->subtotal);
     $invoices->total = $this->_currency->toCurrency($invoices->total);
     return $invoices;
 }
Exemplo n.º 4
0
 protected function getHistory($id)
 {
     $this->_currency->setFormat(array('display' => Zend_Currency::USE_SYMBOL));
     $documentrelationDb = new Application_Model_DbTable_Documentrelation();
     $documentrelations = $documentrelationDb->fetchAll($documentrelationDb->select()->where('contactid = ?', $id));
     $documentrelationIDs = array();
     foreach ($documentrelations as $documentrelation) {
         if (!isset($documentrelationIDs[$documentrelation['module']][$documentrelation['controller']])) {
             $documentrelationIDs[$documentrelation['module']][$documentrelation['controller']] = array();
         }
         array_push($documentrelationIDs[$documentrelation['module']][$documentrelation['controller']], $documentrelation['documentid']);
     }
     //Quotes
     $quoteDb = new Sales_Model_DbTable_Quote();
     if (isset($documentrelationIDs['sales']['quote'])) {
         $history['quotes'] = $quoteDb->fetchAll($quoteDb->select()->where('contactid = ?', $id)->where('clientid = ?', $this->_user['clientid'])->orWhere('id IN (?)', $documentrelationIDs['sales']['quote'])->where('clientid = ?', $this->_user['clientid']));
     } else {
         $history['quotes'] = $quoteDb->fetchAll($quoteDb->select()->where('contactid = ?', $id)->where('clientid = ?', $this->_user['clientid']));
     }
     foreach ($history['quotes'] as $quote) {
         $quote->subtotal = $this->_currency->toCurrency($quote->subtotal);
         $quote->taxes = $this->_currency->toCurrency($quote->taxes);
         $quote->total = $this->_currency->toCurrency($quote->total);
         if ($quote->quotedate && $quote->quotedate != '0000-00-00') {
             $quote->quotedate = date('d.m.Y', strtotime($quote->quotedate));
         }
         if ($quote->modified && $quote->modified != '0000-00-00') {
             $quote->modified = date('d.m.Y', strtotime($quote->modified));
         }
         if ($quote->deliverydate && $quote->deliverydate != '0000-00-00') {
             $quote->deliverydate = date('d.m.Y', strtotime($quote->deliverydate));
         }
     }
     //Sales orders
     $salesorderDb = new Sales_Model_DbTable_Salesorder();
     if (isset($documentrelationIDs['sales']['salesorder'])) {
         $history['salesorders'] = $salesorderDb->fetchAll($salesorderDb->select()->where('contactid = ?', $id)->where('clientid = ?', $this->_user['clientid'])->orWhere('id IN (?)', $documentrelationIDs['sales']['salesorder'])->where('clientid = ?', $this->_user['clientid']));
     } else {
         $history['salesorders'] = $salesorderDb->fetchAll($salesorderDb->select()->where('contactid = ?', $id)->where('clientid = ?', $this->_user['clientid']));
     }
     foreach ($history['salesorders'] as $salesorder) {
         $salesorder->subtotal = $this->_currency->toCurrency($salesorder->subtotal);
         $salesorder->taxes = $this->_currency->toCurrency($salesorder->taxes);
         $salesorder->total = $this->_currency->toCurrency($salesorder->total);
         if ($salesorder->salesorderdate && $salesorder->salesorderdate != '0000-00-00') {
             $salesorder->salesorderdate = date('d.m.Y', strtotime($salesorder->salesorderdate));
         }
         if ($salesorder->modified && $salesorder->modified != '0000-00-00') {
             $salesorder->modified = date('d.m.Y', strtotime($salesorder->modified));
         }
         if ($salesorder->deliverydate && $salesorder->deliverydate != '0000-00-00') {
             $salesorder->deliverydate = date('d.m.Y', strtotime($salesorder->deliverydate));
         }
     }
     //Invoices
     $invoiceDb = new Sales_Model_DbTable_Invoice();
     if (isset($documentrelationIDs['sales']['invoice'])) {
         $history['invoices'] = $invoiceDb->fetchAll($invoiceDb->select()->where('contactid = ?', $id)->where('clientid = ?', $this->_user['clientid'])->orWhere('id IN (?)', $documentrelationIDs['sales']['invoice'])->where('clientid = ?', $this->_user['clientid']));
     } else {
         $history['invoices'] = $invoiceDb->fetchAll($invoiceDb->select()->where('contactid = ?', $id)->where('clientid = ?', $this->_user['clientid']));
     }
     foreach ($history['invoices'] as $invoice) {
         $invoice->subtotal = $this->_currency->toCurrency($invoice->subtotal);
         $invoice->taxes = $this->_currency->toCurrency($invoice->taxes);
         $invoice->total = $this->_currency->toCurrency($invoice->total);
         if ($invoice->invoicedate && $invoice->invoicedate != '0000-00-00') {
             $invoice->invoicedate = date('d.m.Y', strtotime($invoice->invoicedate));
         }
         if ($invoice->modified && $invoice->modified != '0000-00-00') {
             $invoice->modified = date('d.m.Y', strtotime($invoice->modified));
         }
         if ($invoice->deliverydate && $invoice->deliverydate != '0000-00-00') {
             $invoice->deliverydate = date('d.m.Y', strtotime($invoice->deliverydate));
         }
     }
     //Delivery orders
     $deliveryorderDb = new Sales_Model_DbTable_Deliveryorder();
     if (isset($documentrelationIDs['sales']['deliveryorder'])) {
         $history['deliveryorders'] = $deliveryorderDb->fetchAll($deliveryorderDb->select()->where('contactid = ?', $id)->where('clientid = ?', $this->_user['clientid'])->orWhere('id IN (?)', $documentrelationIDs['sales']['deliveryorder'])->where('clientid = ?', $this->_user['clientid']));
     } else {
         $history['deliveryorders'] = $deliveryorderDb->fetchAll($deliveryorderDb->select()->where('contactid = ?', $id)->where('clientid = ?', $this->_user['clientid']));
     }
     foreach ($history['deliveryorders'] as $deliveryorder) {
         $deliveryorder->subtotal = $this->_currency->toCurrency($deliveryorder->subtotal);
         $deliveryorder->taxes = $this->_currency->toCurrency($deliveryorder->taxes);
         $deliveryorder->total = $this->_currency->toCurrency($deliveryorder->total);
         if ($deliveryorder->deliveryorderdate && $deliveryorder->deliveryorderdate != '0000-00-00') {
             $deliveryorder->deliveryorderdate = date('d.m.Y', strtotime($deliveryorder->deliveryorderdate));
         }
         if ($deliveryorder->modified && $deliveryorder->modified != '0000-00-00') {
             $deliveryorder->modified = date('d.m.Y', strtotime($deliveryorder->modified));
         }
         if ($deliveryorder->deliverydate && $deliveryorder->deliverydate != '0000-00-00') {
             $deliveryorder->deliverydate = date('d.m.Y', strtotime($deliveryorder->deliverydate));
         }
     }
     //Credit notes
     $creditnoteDb = new Sales_Model_DbTable_Creditnote();
     if (isset($documentrelationIDs['sales']['creditnote'])) {
         $history['creditnotes'] = $creditnoteDb->fetchAll($creditnoteDb->select()->where('contactid = ?', $id)->where('clientid = ?', $this->_user['clientid'])->orWhere('id IN (?)', $documentrelationIDs['sales']['creditnote'])->where('clientid = ?', $this->_user['clientid']));
     } else {
         $history['creditnotes'] = $creditnoteDb->fetchAll($creditnoteDb->select()->where('contactid = ?', $id)->where('clientid = ?', $this->_user['clientid']));
     }
     foreach ($history['creditnotes'] as $creditnote) {
         $creditnote->subtotal = $this->_currency->toCurrency($creditnote->subtotal);
         $creditnote->taxes = $this->_currency->toCurrency($creditnote->taxes);
         $creditnote->total = $this->_currency->toCurrency($creditnote->total);
         if ($creditnote->creditnotedate && $creditnote->creditnotedate != '0000-00-00') {
             $creditnote->creditnotedate = date('d.m.Y', strtotime($creditnote->creditnotedate));
         }
         if ($creditnote->modified && $creditnote->modified != '0000-00-00') {
             $creditnote->modified = date('d.m.Y', strtotime($creditnote->modified));
         }
         if ($creditnote->deliverydate && $creditnote->deliverydate != '0000-00-00') {
             $creditnote->deliverydate = date('d.m.Y', strtotime($creditnote->deliverydate));
         }
     }
     //Quote requests
     $quoterequestDb = new Purchases_Model_DbTable_Quoterequest();
     if (isset($documentrelationIDs['purchases']['quoterequest'])) {
         $history['quoterequests'] = $quoterequestDb->fetchAll($quoterequestDb->select()->where('contactid = ?', $id)->where('clientid = ?', $this->_user['clientid'])->orWhere('id IN (?)', $documentrelationIDs['purchases']['quoterequest'])->where('clientid = ?', $this->_user['clientid']));
     } else {
         $history['quoterequests'] = $quoterequestDb->fetchAll($quoterequestDb->select()->where('contactid = ?', $id)->where('clientid = ?', $this->_user['clientid']));
     }
     foreach ($history['quoterequests'] as $quoterequest) {
         $quoterequest->subtotal = $this->_currency->toCurrency($quoterequest->subtotal);
         $quoterequest->taxes = $this->_currency->toCurrency($quoterequest->taxes);
         $quoterequest->total = $this->_currency->toCurrency($quoterequest->total);
         if ($quoterequest->quoterequestdate && $quoterequest->quoterequestdate != '0000-00-00') {
             $quoterequest->quoterequestdate = date('d.m.Y', strtotime($quoterequest->quoterequestdate));
         }
         if ($quoterequest->modified && $quoterequest->modified != '0000-00-00') {
             $quoterequest->modified = date('d.m.Y', strtotime($quoterequest->modified));
         }
         if ($quoterequest->deliverydate && $quoterequest->deliverydate != '0000-00-00') {
             $quoterequest->deliverydate = date('d.m.Y', strtotime($quoterequest->deliverydate));
         }
     }
     //Purchase orders
     $purchaseorderDb = new Purchases_Model_DbTable_Purchaseorder();
     if (isset($documentrelationIDs['purchases']['purchaseorder'])) {
         $history['purchaseorders'] = $purchaseorderDb->fetchAll($purchaseorderDb->select()->where('contactid = ?', $id)->where('clientid = ?', $this->_user['clientid'])->orWhere('id IN (?)', $documentrelationIDs['purchases']['purchaseorder'])->where('clientid = ?', $this->_user['clientid']));
     } else {
         $history['purchaseorders'] = $purchaseorderDb->fetchAll($purchaseorderDb->select()->where('contactid = ?', $id)->where('clientid = ?', $this->_user['clientid']));
     }
     foreach ($history['purchaseorders'] as $purchaseorder) {
         $purchaseorder->subtotal = $this->_currency->toCurrency($purchaseorder->subtotal);
         $purchaseorder->taxes = $this->_currency->toCurrency($purchaseorder->taxes);
         $purchaseorder->total = $this->_currency->toCurrency($purchaseorder->total);
     }
     //Processes
     $processesDb = new Processes_Model_DbTable_Process();
     $history['processes'] = $processesDb->fetchAll($processesDb->select()->where('customerid = ?', $id));
     /*foreach($history['processes'] as $process) {
     			$process->subtotal = $this->_currency->toCurrency($process->subtotal);
     			$process->taxes = $this->_currency->toCurrency($process->taxes);
     			$process->total = $this->_currency->toCurrency($process->total);
     		}*/
     return $history;
 }