/** * returns array of all users * [userID] => 23103741 * [name] => admin * [mail] => 0 * [active] => 0 * * @param int $trash * @param array $groups list of group ids the users must be a member of * @return array * @author th */ public function get_users($trash = 0, array $groups = null) { $p = $this->kga['server_prefix']; $trash = MySQL::SQLValue($trash, MySQL::SQLVALUE_NUMBER); if (empty($groups)) { $query = "SELECT * FROM {$p}users\n WHERE trash = {$trash}\n ORDER BY name ;"; } else { $query = "SELECT DISTINCT u.* FROM {$p}users AS u\n JOIN {$p}groups_users AS g_u USING(userID)\n WHERE g_u.groupID IN (" . implode($groups, ',') . ") AND\n trash = {$trash}\n ORDER BY name ;"; } $this->conn->Query($query); $rows = $this->conn->RowArray(0, MYSQLI_ASSOC); $i = 0; $arr = array(); $this->conn->MoveFirst(); while (!$this->conn->EndOfSeek()) { $row = $this->conn->Row(); $arr[$i]['userID'] = $row->userID; $arr[$i]['name'] = $row->name; $arr[$i]['globalRoleID'] = $row->globalRoleID; $arr[$i]['mail'] = $row->mail; $arr[$i]['active'] = $row->active; $arr[$i]['trash'] = $row->trash; if ($row->password != '' && $row->password != '0') { $arr[$i]['passwordSet'] = "yes"; } else { $arr[$i]['passwordSet'] = "no"; } $i++; } return $arr; }
public function memberList() { $db = new MySQL(true, 'color64', 'localhost', 'color64', 'nu5Jc4JdtZK4RCHH'); $q = $db->Query("SELECT `id`,`name` FROM `users` WHERE `id` > 1 ORDER BY `id` ASC;"); $mlist = array(); while (!$db->EndOfSeek()) { $l = $db->Row(); $mlist[$l->id] = strtoupper($l->name); } return $mlist; }
function startFillSpecificPrice() { $sql = "SELECT * FROM erp_sconti_scaglione ORDER BY priority ASC"; $db = new MySQL(); $db->Query($sql); $row = NULL; if ($db->RowCount() > 0) { while (!$db->EndOfSeek()) { $row[] = $db->Row(); } } $this->_GLOBAL_COUNTER = 0; foreach ($row as $sconto_erp) { $specific_price = new \stdClass(); $specific_price->priority = $sconto_erp->priority; if (!empty($sconto_erp->CDprodotto) and !empty($sconto_erp->CDanag)) { $infoReduction = explode(";", $this->calculateREduction(array($sconto_erp->NRsconto))); $cdprodotto = $sconto_erp->CDprodotto; $cdanag = $sconto_erp->CDanag; $specific_price->price = $sconto_erp->Nrprezzo; $specific_price->from_quantity = $sconto_erp->NRqtaLimite; $specific_price->reduction = $infoReduction[0]; if ($specific_price->reduction == 1) { $specific_price->reduction = 0; } $specific_price->reduction_type = "percentage"; if ($specific_price->reduction == 0) { $specific_price->reduction_type = "amount"; } $specific_price->from = $sconto_erp->Dtinizio; $specific_price->to = $sconto_erp->Dtfine; $specific_price->stringSconto = $infoReduction[1]; $specific_price->type = $sconto_erp->priority . "_" . $sconto_erp->id; $id_product = $this->getIdProductFromCode($cdprodotto); $id_customer = $this->getCustomerIdFromCode($cdanag); if ($sconto_erp->Nrprezzo == 0.0) { if (PROPAPAGAZIONE_LISTINI_CLIENTI == 1 && isset($this->_APP1O_LIST_BASE[$cdanag])) { $appo_split = explode("_", $this->_APPO_LIST_BASE[$cdanag]); $id_listino = $appo_split[0]; $list_sconto = $appo_split[1]; $specific_price->price = $this->_GROUP_MISTO_PER_LISTINI[$id_listino][$list_sconto]['specific_price'][$cdprodotto]->price; } else { $specific_price->price = -1; } } $id_group = 0; if ($cdanag == "CCORRI") { $id_customer = null; $id_group = 1; } if ($id_product != null and $id_group == 1) { $this->checkIfExistsHighPriceRuleCCORRI($specific_price, $id_product); } if ($id_customer != null and $id_product != null) { $this->checkIfExistsHighPriceRule($specific_price, $id_product, $id_customer); } } else { if (!empty($sconto_erp->CDprodotto) and !empty($sconto_erp->Cdcatcli)) { foreach ($this->ERP_CATCUSTOMER[$sconto_erp->Cdcatcli] as $cdanag) { $infoReduction = explode(";", $this->calculateREduction(array($sconto_erp->NRsconto))); $cdprodotto = $sconto_erp->CDprodotto; $specific_price->price = $sconto_erp->Nrprezzo; $specific_price->from_quantity = $sconto_erp->NRqtaLimite; $specific_price->reduction = $infoReduction[0]; if ($specific_price->reduction == 1) { $specific_price->reduction = 0; } $specific_price->reduction_type = "percentage"; if ($specific_price->reduction == 0) { $specific_price->reduction_type = "amount"; } $specific_price->from = $sconto_erp->Dtinizio; $specific_price->to = $sconto_erp->Dtfine; $specific_price->stringSconto = $infoReduction[1]; $specific_price->type = $sconto_erp->priority . "_" . $sconto_erp->id; $id_product = $this->getIdProductFromCode($cdprodotto); $id_customer = $this->getCustomerIdFromCode($cdanag); if ($sconto_erp->Nrprezzo == 0.0) { if (PROPAPAGAZIONE_LISTINI_CLIENTI == 1 && isset($this->_APP1O_LIST_BASE[$cdanag])) { $appo_split = explode("_", $this->_APPO_LIST_BASE[$cdanag]); $id_listino = $appo_split[0]; $list_sconto = $appo_split[1]; $specific_price->price = $this->_GROUP_MISTO_PER_LISTINI[$id_listino][$list_sconto]['specific_price'][$cdprodotto]->price; } else { $specific_price->price = -1; } } $id_group = 0; if ($cdanag == "CCORRI") { $id_customer = null; $id_group = 1; } if ($id_product != null and $id_group == 1) { $this->checkIfExistsHighPriceRuleCCORRI($specific_price, $id_product); } if ($id_customer != null and $id_customer != "" and $id_product != null) { $this->checkIfExistsHighPriceRule($specific_price, $id_product, $id_customer); } } } else { if (!empty($sconto_erp->Cdcatart) and !empty($sconto_erp->CDanag)) { $arrayProductInCat = $this->getProductInsideCategory($sconto_erp->Cdcatart); if (!empty($arrayProductInCat) and count($arrayProductInCat) > 0) { foreach ($arrayProductInCat as $CdprodottoObj) { $cdprodotto = $CdprodottoObj->code; $infoReduction = explode(";", $this->calculateREduction(array($sconto_erp->NRsconto))); $cdanag = $sconto_erp->CDanag; $specific_price->price = $sconto_erp->Nrprezzo; $specific_price->from_quantity = $sconto_erp->NRqtaLimite; $specific_price->reduction = $infoReduction[0]; if ($specific_price->reduction == 1) { $specific_price->reduction = 0; } $specific_price->reduction_type = "percentage"; if ($specific_price->reduction == 0) { $specific_price->reduction_type = "amount"; } $specific_price->from = $sconto_erp->Dtinizio; $specific_price->to = $sconto_erp->Dtfine; $specific_price->stringSconto = $infoReduction[1]; $specific_price->type = $sconto_erp->priority . "_" . $sconto_erp->id; $id_product = $this->getIdProductFromCode($cdprodotto); $id_customer = $this->getCustomerIdFromCode($cdanag); if ($sconto_erp->Nrprezzo == 0.0) { if (PROPAPAGAZIONE_LISTINI_CLIENTI == 1 && isset($this->_APP1O_LIST_BASE[$cdanag])) { $appo_split = explode("_", $this->_APPO_LIST_BASE[$cdanag]); $id_listino = $appo_split[0]; $list_sconto = $appo_split[1]; $specific_price->price = $this->_GROUP_MISTO_PER_LISTINI[$id_listino][$list_sconto]['specific_price'][$cdprodotto]->price; } else { $specific_price->price = -1; } } $id_group = 0; if ($cdanag == "CCORRI") { $id_customer = null; $id_group = 1; } if ($id_product != null and $id_group == 1) { $this->checkIfExistsHighPriceRuleCCORRI($specific_price, $id_product); } if ($id_customer != null and $id_product != null) { $this->checkIfExistsHighPriceRule($specific_price, $id_product, $id_customer); } } } } else { if (!empty($sconto_erp->Cdcatart) and !empty($sconto_erp->Cdcatcli)) { foreach ($this->ERP_CATCUSTOMER[$sconto_erp->Cdcatcli] as $cdanag) { $arrayProductInCat = $this->getProductInsideCategory($sconto_erp->Cdcatart); if (!empty($arrayProductInCat) and count($arrayProductInCat) > 0) { foreach ($arrayProductInCat as $CdprodottoObj) { $infoReduction = explode(";", $this->calculateREduction(array($sconto_erp->NRsconto))); $cdprodotto = $CdprodottoObj->code; $specific_price->price = $sconto_erp->Nrprezzo; $specific_price->from_quantity = $sconto_erp->NRqtaLimite; $specific_price->reduction = $infoReduction[0]; if ($specific_price->reduction == 1) { $specific_price->reduction = 0; } $specific_price->reduction_type = "percentage"; if ($specific_price->reduction == 0) { $specific_price->reduction_type = "amount"; } $specific_price->from = $sconto_erp->Dtinizio; $specific_price->to = $sconto_erp->Dtfine; $specific_price->stringSconto = $infoReduction[1]; $specific_price->type = $sconto_erp->priority . "_" . $sconto_erp->id; $id_product = $this->getIdProductFromCode($cdprodotto); $id_customer = $this->getCustomerIdFromCode($cdanag); if ($sconto_erp->Nrprezzo == 0.0) { //if (isset($this -> _GESTIONE_PREZZI[11][$cdprodotto . "-" . $cdanag])) { /* if (isset($this -> _MAPPING_ANAG_IDLISTINO[$cdanag]) and isset($this -> GROUP_LISTINI_BASE[$this -> _MAPPING_ANAG_IDLISTINO[$cdanag]][$cdprodotto] -> price)) { //$specific_price -> price = $this -> _GESTIONE_PREZZI[11][$cdprodotto . "-" . $cdanag] -> price; $specific_price -> price = $this -> GROUP_LISTINI_BASE[$this -> _MAPPING_ANAG_IDLISTINO[$cdanag]][$cdprodotto] -> price; } else { $specific_price -> price = -1; } */ if (PROPAPAGAZIONE_LISTINI_CLIENTI == 1 && isset($this->_APP1O_LIST_BASE[$cdanag])) { $appo_split = explode("_", $this->_APPO_LIST_BASE[$cdanag]); $id_listino = $appo_split[0]; $list_sconto = $appo_split[1]; $specific_price->price = $this->_GROUP_MISTO_PER_LISTINI[$id_listino][$list_sconto]['specific_price'][$cdprodotto]->price; } else { $specific_price->price = -1; } } $id_group = 0; if ($cdanag == "CCORRI") { $id_customer = null; $id_group = 1; } if ($id_product != null and $id_group == 1) { $this->checkIfExistsHighPriceRuleCCORRI($specific_price, $id_product); } if ($id_customer != null and $id_product != null) { $this->checkIfExistsHighPriceRule($specific_price, $id_product, $id_customer); } } } } } else { // sconti scaglione $infoReduction = explode(";", $this->calculateREduction(array($sconto_erp->NRsconto))); $cdprodotto = $sconto_erp->CDprodotto; $cdanag = 0; $specific_price->price = $sconto_erp->Nrprezzo; $specific_price->from_quantity = $sconto_erp->NRqtaLimite; $specific_price->reduction = $infoReduction[0]; if ($specific_price->reduction == 1) { $specific_price->reduction = 0; } $specific_price->reduction_type = "percentage"; if ($specific_price->reduction == 0) { $specific_price->reduction_type = "amount"; } $specific_price->from = $sconto_erp->Dtinizio; $specific_price->to = $sconto_erp->Dtfine; $specific_price->stringSconto = $infoReduction[1]; $specific_price->type = $sconto_erp->priority . "_" . $sconto_erp->id; $id_product = $this->getIdProductFromCode($cdprodotto); //$id_customer = $this -> getCustomerIdFromCode($cdanag); if ($sconto_erp->Nrprezzo == 0.0) { $specific_price->price = -1; } if (PROPAPAGAZIONE_LISTINI_CLIENTI == 0) { $specific_price->price = -1; } if ($id_product != null) { $this->checkIfExistsHighPriceRule($specific_price, $id_product, 0); } } } } } } }
// --- Query and show the data -------------------------------------- // (Note: $db->Query also returns the result set) if ($db->Query("SELECT * FROM Test")) { echo $db->GetHTML(); } else { echo "<p>Query Failed</p>"; } // --- Getting the record count is easy ----------------------------- echo "\n<p>Record Count: " . $db->RowCount() . "</p>\n"; // --- Loop through the records ------------------------------------- while ($row = $db->Row()) { echo $row->Color . " - " . $row->Age . "<br />\n"; } // --- Loop through the records another way ------------------------- $db->MoveFirst(); while (!$db->EndOfSeek()) { $row = $db->Row(); echo $row->Color . " - " . $row->Age . "<br />\n"; } // --- Loop through the records with an index ----------------------- for ($index = 0; $index < $db->RowCount(); $index++) { $row = $db->Row($index); echo "Row " . $index . ":" . $row->Color . " - " . $row->Age . "<br />\n"; } // --- We can even grab array data from the last result set --------- $myArray = $db->RecordsArray(); // --- List all of the tables in the database ----------------------- $tables = $db->GetTables(); foreach ($tables as $table) { echo $table . "<br />\n"; }
function getCategoryStringForLayeredTemplate() { $db = new MySQL(); $sql = "SELECT id_category FROM ps_category WHERE id_category > 1"; $result = $db->Query($sql); while (!$db->EndOfSeek()) { $row[] = $db->Row(); } $categoryArray = array(); foreach ($row as $id_category) { $categoryArray[] = $id_category->id_category; } return $categoryArray; }
function backupDatabase($dbName, $backupStructure = true, $backupData = true, $backupFile = null) { $columnName = 'Tables_in_' . $dbName; $this->done = false; $this->output .= "-- SQL Dump File \n"; $this->output .= "-- Generation Time: " . date('M j, Y') . " at " . date('h:i:s A') . " \n\n"; $this->output .= "-- \n"; $this->output .= "-- Database: `{$dbName}` \n"; $this->output .= "-- \n\n"; $conn = new MySQL(true, DBNAME, DBHOST, DBUSER, DBPASS, "", true); $strTables = 'SHOW TABLES'; $conn->Query($strTables); $cntTables = $conn->RowCount(); if ($cntTables) { $conn->MoveFirst(); while (!$conn->EndOfSeek()) { $rsTables = $conn->Row(); if ($backupStructure) { $this->dumpTableStructure($rsTables->{$columnName}); } if ($backupData) { $this->dumpTableData($rsTables->{$columnName}); } } } else { $this->output .= "-- \n"; $this->output .= "-- No tables in {$dbName} \n"; $this->output .= "-- \n"; } if (!is_null($backupFile)) { $this->dumpToFile($backupFile); } $this->done = true; }
/** * Resetta le immagini del prodotto * * @param int $id_product Id del prodotto */ function resetImages($id_product) { $sql = "SELECT id_image FROM ps_image WHERE id_product = {$id_product}"; $db = new MySQL(); $db->Query($sql); $row = NULL; if ($db->RowCount() > 0) { while (!$db->EndOfSeek()) { $row[] = $db->Row(); } foreach ($row as $appoRow) { $this->reinitImageLang($appoRow->id_image); $this->reinitImageShop($appoRow->id_image); } } }
/** * Metodo utilizzato per recuperare tutti gli utenti attivi in Prestashop * * @return type */ function getEnabledCustomer() { $sql = "SELECT * FROM ps_customer WHERE active = 1"; $db = new MySQL(); $db->Query($sql); $row = NULL; if ($db->RowCount() > 0) { while (!$db->EndOfSeek()) { $appoRow = $db->Row(); $row[] = $appoRow->id_customer; } } return $row; }
/** * Metodo che seleziona i gruppi dalla tabelal ps_group * @return Object Lista di strutture contenente id_group per ogni gruppo */ function getGroupId() { $db = new MySQL(); $sql = "SELECT id_group FROM ps_group"; $db->Query($sql); $row = NULL; if ($db->RowCount() > 0) { while (!$db->EndOfSeek()) { $row[] = $db->Row(); } } return $row; }
/** * Metodo per a creazione del file di indirizzi (indirizzi fatturazione - spedizione) */ function getIndirizzi() { /* * La richiesta � quella di gestire anche un 4� file, denominato FWINDIRIZZI, che contenga tutti gli indirizzi di spedizione. * * */ $query = "SELECT \n\t\tid_address,\n\t customer_code,\n\t\tcompany,\n\t\tfirstname,\n\t\tlastname,\n\t\tCONCAT(address1, ' ', address2) as full_address,\n\t\tpostcode,\n\t\tcity,\n\t\tstate_name,\n\t\tphone,\n\t\tphone_mobile,\n\t\tvat_number\n\t\t\n\t\tFROM ps_address \n\t\tLEFT JOIN (SELECT code as customer_code, id_customer from ps_customer) AS ps_customer_joined ON ps_customer_joined.id_customer = ps_address.id_customer\n\t\tLEFT JOIN (SELECT name as state_name, id_state from ps_state) as ps_state_joined ON ps_state_joined.id_state = ps_address.id_state\n\t\t\n\t\tWHERE ((synch = 0)AND(NOT(alias LIKE 'fatturazione')))"; $db = new MySQL(); $db->Query($query); $row = NULL; if ($db->RowCount() > 0) { while (!$db->EndOfSeek()) { $row[] = $db->Row(); } } foreach ($row as $anag) { /* DOC: 2.1) TABELLA FWINDIRIZZI (1) La tabella FWINDIRIZZI potr� avere un tracciato record ricavato da quello della tabella �ps_address� di Presta Shop: Campo Valori Chiave Descrizione campo ID_Address int si Numero univoco indirizzo CdCustomer char(50) no Codice del cliente, ricavato dalla tabella ps_customer Company char(64) no Ragione sociale Cognome char(32) no Cognome, da concatenare con Nome e importare in DestDiv.Des2Dest Nome char(32) no Vedi sopra Address char(128) no Indirizzo Zip char(12) no Codice Avviamento Postale City char(64) no Localit� NB. -> ripetizione. elimino => City char(64) no Localit� Prov char(5) no Sigla Provincia, ricavato da ID_State o ID_Country ? Phone char(32) no Telefono PhoneMob char(32) no Cellulare, da importare in Contatto VATnum char(32) no Partita IVA */ $stringa = null; $stringa[] = $anag->id_address; $stringa[] = $anag->customer_code; $stringa[] = !empty($anag->company) ? $anag->company : "-Senza Ragione Sociale-"; $stringa[] = !empty($anag->lastname) ? $anag->lastname : "-Senza Cognome-"; $stringa[] = !empty($anag->firstname) ? $anag->firstname : "-Senza Nome-"; $stringa[] = !empty($anag->full_address) ? $anag->full_address : "-Senza Indirizzo-"; $stringa[] = $anag->postcode; $stringa[] = $anag->city; $stringa[] = $anag->state_name; $stringa[] = $anag->phone; $stringa[] = $anag->phone_mobile; $stringa[] = !empty($anag->vat_number) ? $anag->vat_number : "-Senza Partita Iva-"; file_put_contents($this->fileFWINDIRIZZI, iconv(mb_detect_encoding(implode("§", $stringa), mb_detect_order(), true), "UTF-8", implode("§", $stringa)) . "\r\n", FILE_APPEND); $this->setAnagraficaSynchronized($anag->id_address); /* $stringa = null; $stringa[] = $this->fillCodeClientiWithZero($this -> getCodeClienti(), $anag -> id_customer); // CDute [0] $appo = null; $appo = $this -> getSIngleAnagFromId($anag -> id_customer); if (!empty($appo -> company)) { $stringa[] = $appo -> company; // DSRaso [1] } else { $stringa[] = "-Senza Ragione Sociale-"; } if (!empty($anag -> lastname)) { $stringa[] = $anag -> lastname; // DSCognome [2] } else { $stringa[] = "-Senza Cognome-"; } if (!empty($anag -> firstname)) { $stringa[] = $anag -> firstname; // DSnome [3] } else { $stringa[] = "-Senza Nome-"; } if (!empty($appo -> vat_number)) { $stringa[] = $appo -> vat_number; // DSpiva [4] } else { $stringa[] = "-Senza Partita Iva-"; } if (!empty($appo -> dni)) { $stringa[] = $appo -> dni; // DScod_fis [5] } else { $stringa[] = "-Senza Codice Fiscale-"; } $stringa[] = $appo -> address1; // DSindi [6] $stringa[] = $appo -> postcode; // DScap [7] $stringa[] = $appo -> city; // DSloca [8] $stringa[] = $this -> getStateFromId($appo -> id_state); //$stringa[] = ""; // DSprov [9] $stringa[] = $appo -> phone; // DStel [10] $stringa[] = $appo -> phone_mobile; // DScell [11] $stringa[] = ""; // DSfax [12] $stringa[] = $anag -> email; // DSemail [13] $stringa[] = ""; // null [14] $stringa[] = ""; // null [15] $stringa[] = "IT"; // DSnazione [16] $stringa[] = ""; // MMNota [17] $stringa[] = $anag -> email; // DSlogin [18] $stringa[] = ""; // DSpwd [19] * file_put_contents($this -> fileFWINDIRIZZI, iconv(mb_detect_encoding(implode("§", $stringa), mb_detect_order(), true), "UTF-8", implode("§", $stringa)) . "\r\n", FILE_APPEND); $this -> unselectSingleAnag($anag -> id_customer, $this->fillCodeClientiWithZero($this -> getCodeClienti(), $anag -> id_customer)); */ } }