/** * 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'], 'email' => $customerdata['email'], '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' => lms_ucwords($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=?, email=?, 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; }
function CustomerUpdate($customerdata) { $res = $this->DB->Execute('UPDATE customers SET status=?, type=?, address=?, zip=?, city=?, countryid=?, email=?, 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($customerdata['status'], empty($customerdata['type']) ? 0 : 1, $customerdata['address'], $customerdata['zip'], $customerdata['city'], $customerdata['countryid'], $customerdata['email'], $customerdata['ten'], $customerdata['ssn'], isset($this->AUTH->id) ? $this->AUTH->id : 0, $customerdata['post_name'], $customerdata['post_address'], $customerdata['post_zip'], $customerdata['post_city'], $customerdata['post_countryid'], $customerdata['info'], $customerdata['notes'], $customerdata['lastname'], lms_ucwords($customerdata['name']), $customerdata['message'], $customerdata['pin'], $customerdata['regon'], $customerdata['icn'], $customerdata['rbe'], $customerdata['cutoffstop'], $customerdata['consentdate'], $customerdata['einvoice'], $customerdata['invoicenotice'], $customerdata['mailingnotice'], $customerdata['divisionid'], $customerdata['paytime'], $customerdata['paytype'] ? $customerdata['paytype'] : null, $customerdata['id'])); if ($res) { $this->UpdateCountryState($customerdata['zip'], $customerdata['stateid']); if ($customerdata['post_zip'] != $customerdata['zip']) { $this->UpdateCountryState($customerdata['post_zip'], $customerdata['post_stateid']); } } return $res; }
function ContractorUpdate($customerdata) { // if (SYSLOG) $diff['old'] = $this->getcontractor($customerdata['id']); $res = $this->DB->Execute('UPDATE customers SET lastname=?, name=?, address=?, zip=?, city=?, countryid=?, post_name=?, post_address=?, post_zip=?, post_city=?, post_countryid=?, email=?, account=?, ten=?, regon=?, rbe=?, pin=?, paytime=?, paytype=?, info=?, notes=?, moddate=?NOW?, modid=?, deleted=0, consentdate=?, einvoice=?, invoicenotice=?, mailingnotice=?, divisionid=?, url=? WHERE id=?', array($customerdata['lastname'] ? $customerdata['lastname'] : '', $customerdata['name'] ? lms_ucwords($customerdata['name']) : '', $customerdata['address'] ? $customerdata['address'] : '', $customerdata['zip'] ? $customerdata['zip'] : '', $customerdata['city'] ? $customerdata['city'] : '', $customerdata['countryid'] ? $customerdata['countryid'] : NULL, $customerdata['post_name'] ? $customerdata['post_name'] : NULL, $customerdata['post_address'] ? $customerdata['post_address'] : NULL, $customerdata['post_zip'] ? $customerdata['post_zip'] : NULL, $customerdata['post_city'] ? $customerdata['post_city'] : NULL, $customerdata['post_countryid'] ? $customerdata['post_countryid'] : NULL, $customerdata['email'] ? $customerdata['email'] : '', $customerdata['account'] ? $customerdata['account'] : NULL, $customerdata['ten'] ? $customerdata['ten'] : '', $customerdata['regon'] ? $customerdata['regon'] : '', $customerdata['rbe'] ? $customerdata['rbe'] : '', $customerdata['pin'] ? $customerdata['pin'] : '', $customerdata['paytime'] ? $customerdata['paytime'] : '-1', $customerdata['paytype'] ? $customerdata['paytype'] : NULL, $customerdata['info'] ? $customerdata['info'] : '', $customerdata['notes'] ? $customerdata['notes'] : '', isset($this->AUTH->id) ? $this->AUTH->id : 0, $customerdata['consentdate'] ? $customerdata['consentdate'] : 0, $customerdata['einvoice'] ? $customerdata['einvoice'] : NULL, $customerdata['invoicenotice'] ? $customerdata['invoicenotice'] : NULL, $customerdata['mailingnotice'] ? $customerdata['mailingnotice'] : NULL, $customerdata['divisionid'] ? $customerdata['divisionid'] : 0, $customerdata['url'] ? $customerdata['url'] : NULL, $customerdata['id'])); if ($res) { $this->UpdateCountryState($customerdata['zip'], $customerdata['stateid']); if ($customerdata['post_zip'] != $customerdata['zip']) { $this->UpdateCountryState($customerdata['post_zip'], $customerdata['post_stateid']); } if (SYSLOG) { // $diff['type'] = 'up'; // $diff['dbtable'] = 'customers'; addlogs('Aktualizacja danych, kontrahent: ' . strtoupper($customerdata['lastname']) . ' ' . $customerdata['name'], 'e=up;m=con;c=' . $customerdata['id']); } } return $res; }
function CustomerExport($customerid) { $customeradd = $this->DB->GetRow('SELECT * FROM customers WHERE id = ?', array($customerid)); if ($customeradd['tv_cust_number']) { $mode = 'edit'; $cust_number = $customeradd['tv_cust_number']; } else { $cust_list = $this->CustomerList(); foreach ($cust_list as $cust) { if ($cust['cust_external_id'] == $customerid) { $mode = 'edit'; $cust_number = $cust['cust_number']; break; } else { $mode = 'add'; } } } $cust_data = array('cust_name' => lms_ucwords($customeradd['name']), 'cust_surname' => lms_ucwords($customeradd['lastname']), 'cust_pesel' => $customeradd['ssn'], 'cust_m_city' => $customeradd['city'], 'cust_m_postal_code' => $customeradd['zip'], 'cust_m_street' => $customeradd['address'], 'cust_m_home_nr' => '.', 'cust_m_flat' => '.', 'cust_c_city' => $customeradd['city'], 'cust_c_postal_code' => $customeradd['zip'], 'cust_c_street' => $customeradd['address'], 'cust_c_home_nr' => '.', 'cust_c_flat' => '.', 'cust_email' => $customeradd['email'], 'cust_external_id' => $customeradd['id']); if ($mode == 'edit') { //$this->DB->Execute('UPDATE customers SET cust_number=? WHERE id=?', array($cust_number, $customerid)); $this->s->get('custEdit', array($cust_number, $cust_data)); } else { $cust_data['cust_vod_pin'] = rand(1000, 9999); $cust_data['cust_master_pin'] = rand(1000, 9999); $cust_number = $this->s->get('custAdd', array($cust_data)); $this->DB->Execute('UPDATE customers SET tv_cust_number=? WHERE id=?', array($cust_number, $customerid)); } $this->_cleanCustomerCache($customerid); if ($_SESSION['tv_cache']) { $this->tv_cache->clean(Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG, array('customer')); } return $cust_number; }