Ejemplo n.º 1
0
 /**
  * Updates customer
  * 
  * @global array $SYSLOG_RESOURCE_KEYS
  * @param array $customerdata Customer data
  * @return int Affected rows
  */
 public function customerUpdate($customerdata)
 {
     global $SYSLOG_RESOURCE_KEYS;
     $args = array('status' => $customerdata['status'], 'type' => empty($customerdata['type']) ? 0 : 1, 'address' => $customerdata['address'], 'zip' => $customerdata['zip'], 'city' => $customerdata['city'], $SYSLOG_RESOURCE_KEYS[SYSLOG_RES_COUNTRY] => $customerdata['countryid'], 'ten' => $customerdata['ten'], 'ssn' => $customerdata['ssn'], $SYSLOG_RESOURCE_KEYS[SYSLOG_RES_USER] => isset($this->auth->id) ? $this->auth->id : 0, 'post_name' => $customerdata['post_name'], 'post_address' => $customerdata['post_address'], 'post_zip' => $customerdata['post_zip'], 'post_city' => $customerdata['post_city'], 'post_countryid' => $customerdata['post_countryid'], 'info' => $customerdata['info'], 'notes' => $customerdata['notes'], 'lastname' => $customerdata['lastname'], 'name' => $customerdata['name'], 'message' => $customerdata['message'], 'pin' => $customerdata['pin'], 'regon' => $customerdata['regon'], 'icn' => $customerdata['icn'], 'rbe' => $customerdata['rbe'], 'cutoffstop' => $customerdata['cutoffstop'], 'consentdate' => $customerdata['consentdate'], 'einvoice' => $customerdata['einvoice'], 'invoicenotice' => $customerdata['invoicenotice'], 'mailingnotice' => $customerdata['mailingnotice'], $SYSLOG_RESOURCE_KEYS[SYSLOG_RES_DIV] => $customerdata['divisionid'], 'paytime' => $customerdata['paytime'], 'paytype' => $customerdata['paytype'] ? $customerdata['paytype'] : null, $SYSLOG_RESOURCE_KEYS[SYSLOG_RES_CUST] => $customerdata['id']);
     $res = $this->db->Execute('UPDATE customers SET status=?, type=?, address=?,
                            zip=?, city=?, countryid=?, ten=?, ssn=?, moddate=?NOW?, modid=?,
                            post_name=?, post_address=?, post_zip=?, post_city=?, post_countryid=?,
                            info=?, notes=?, lastname=UPPER(?), name=?,
                            deleted=0, message=?, pin=?, regon=?, icn=?, rbe=?,
                            cutoffstop=?, consentdate=?, einvoice=?, invoicenotice=?, mailingnotice=?,
                            divisionid=?, paytime=?, paytype=?
                            WHERE id=?', array_values($args));
     if ($res) {
         if ($this->syslog) {
             unset($args[$SYSLOG_RESOURCE_KEYS[SYSLOG_RES_USER]]);
             $args['deleted'] = 0;
             $this->syslog->AddMessage(SYSLOG_RES_CUST, SYSLOG_OPER_UPDATE, $args, array($SYSLOG_RESOURCE_KEYS[SYSLOG_RES_CUST], $SYSLOG_RESOURCE_KEYS[SYSLOG_RES_COUNTRY], $SYSLOG_RESOURCE_KEYS[SYSLOG_RES_DIV]));
         }
         $location_manager = new LMSLocationManager($this->db, $this->auth, $this->cache, $this->syslog);
         $location_manager->UpdateCountryState($customerdata['zip'], $customerdata['stateid']);
         if ($customerdata['post_zip'] != $customerdata['zip']) {
             $location_manager->UpdateCountryState($customerdata['post_zip'], $customerdata['post_stateid']);
         }
     }
     return $res;
 }
Ejemplo n.º 2
0
    public function GetNoteContent($id)
    {
        if ($result = $this->db->GetRow('SELECT d.id, d.number, d.name, d.customerid,
				d.userid, d.address, d.zip, d.city, d.countryid, cn.name AS country,
				d.ten, d.ssn, d.cdate, d.numberplanid, d.closed, d.divisionid, d.paytime, 
				(SELECT name FROM users WHERE id = d.userid) AS user, n.template,
				d.div_name AS division_name, d.div_shortname AS division_shortname,
				d.div_address AS division_address, d.div_zip AS division_zip,
				d.div_city AS division_city, d.div_countryid AS division_countryid, 
				d.div_ten AS division_ten, d.div_regon AS division_regon, d.div_account AS account,
				d.div_inv_header AS division_header, d.div_inv_footer AS division_footer,
				d.div_inv_author AS division_author, d.div_inv_cplace AS division_cplace,
				c.pin AS customerpin, c.divisionid AS current_divisionid,
				c.street, c.building, c.apartment,
				c.post_street, c.post_building, c.post_apartment,
				c.post_name, c.post_address, c.post_zip, c.post_city, c.post_countryid
				FROM documents d
				JOIN customeraddressview c ON (c.id = d.customerid)
				LEFT JOIN countries cn ON (cn.id = d.countryid)
				LEFT JOIN numberplans n ON (d.numberplanid = n.id)
				WHERE d.id = ? AND d.type = ?', array($id, DOC_DNOTE))) {
            $result['bankaccounts'] = $this->db->GetCol('SELECT contact FROM customercontacts
				WHERE customerid = ? AND (type & ?) = ?', array($result['customerid'], CONTACT_BANKACCOUNT | CONTACT_INVOICES | CONTACT_DISABLED, CONTACT_BANKACCOUNT | CONTACT_INVOICES));
            if (empty($result['bankaccounts'])) {
                $result['bankaccounts'] = array();
            }
            $result['value'] = 0;
            if (!$result['division_header']) {
                $location_manager = new LMSLocationManager($this->db, $this->auth, $this->cache, $this->syslog);
                $result['division_header'] = $result['division_name'] . "\n" . $result['division_address'] . "\n" . $result['division_zip'] . ' ' . $result['division_city'] . ($result['division_countryid'] && $result['countryid'] && $result['division_countryid'] != $result['countryid'] ? "\n" . trans($location_manager->GetCountryName($result['division_countryid'])) : '') . ($result['division_ten'] != '' ? "\n" . trans('TEN') . ' ' . $result['division_ten'] : '');
            }
            if ($result['content'] = $this->db->GetAll('SELECT
				value, itemid, description 
				FROM debitnotecontents 
				WHERE docid=? 
				ORDER BY itemid', array($id))) {
                foreach ($result['content'] as $idx => $row) {
                    $result['content'][$idx]['value'] = $row['value'];
                    $result['value'] += $row['value'];
                }
            }
            $result['valuep'] = round(($result['value'] - floor($result['value'])) * 100);
            $result['pdate'] = $result['cdate'] + $result['paytime'] * 86400;
            // NOTE: don't waste CPU/mem when printing history is not set:
            if (ConfigHelper::checkValue(ConfigHelper::getConfig('notes.print_balance', false))) {
                if (ConfigHelper::checkValue(ConfigHelper::getConfig('notes.print_balance_history', false))) {
                    $result['customerbalancelist'] = $LMS->GetCustomerBalanceList($result['customerid'], $result['cdate']);
                } else {
                    $result['customerbalancelist'] = $LMS->GetCustomerBalanceList($result['customerid']);
                }
                $result['customerbalancelistlimit'] = ConfigHelper::getConfig('notes.print_balance_history_limit');
            }
            // for backward compatibility
            if ($result['post_name'] || $result['post_address']) {
                $result['serviceaddr'] = $result['post_name'];
                if ($result['post_address']) {
                    $result['serviceaddr'] .= "\n" . $result['post_address'];
                }
                if ($result['post_zip'] && $result['post_city']) {
                    $result['serviceaddr'] .= "\n" . $result['post_zip'] . ' ' . $result['post_city'];
                }
            }
            return $result;
        } else {
            return FALSE;
        }
    }