diff --git a/htdocs/boutique/commande/class/boutiquecommande.class.php b/htdocs/boutique/commande/class/boutiquecommande.class.php index b46eab9b20f..561607e8daf 100644 --- a/htdocs/boutique/commande/class/boutiquecommande.class.php +++ b/htdocs/boutique/commande/class/boutiquecommande.class.php @@ -66,10 +66,9 @@ class BoutiqueCommande $sql.= " WHERE orders_id = ".$id; $result = $this->db->query($sql) ; - if ( $result ) { - $array = $this->db->fetch_array(); + $array = $this->db->fetch_array($result); $this->id = $array["orders_id"]; $this->client_id = stripslashes($array["customers_id"]); diff --git a/htdocs/boutique/critiques/class/critique.class.php b/htdocs/boutique/critiques/class/critique.class.php index 3b67dbb5ddb..844c2932c51 100644 --- a/htdocs/boutique/critiques/class/critique.class.php +++ b/htdocs/boutique/critiques/class/critique.class.php @@ -29,52 +29,52 @@ * \brief Classe permettant la gestion des critiques OSCommerce */ class Critique { - var $db ; + var $db ; - var $id ; - var $nom; + var $id ; + var $nom; - function Critique($DB, $id=0) { - $this->db = $DB; - $this->id = $id ; - } - /* - * - * - * - */ - function fetch ($id) { - global $conf; + function Critique($DB, $id=0) { + $this->db = $DB; + $this->id = $id ; + } + /* + * + * + * + */ + function fetch ($id) { + global $conf; - $sql = "SELECT r.reviews_id, r.reviews_rating, d.reviews_text, p.products_name"; + $sql = "SELECT r.reviews_id, r.reviews_rating, d.reviews_text, p.products_name"; - $sql .= " FROM ".$conf->global->OSC_DB_NAME.".".$conf->global->OSC_DB_TABLE_PREFIX."reviews as r, ".$conf->global->OSC_DB_NAME.".".$conf->global->OSC_DB_TABLE_PREFIX."reviews_description as d"; - $sql .= " ,".$conf->global->OSC_DB_NAME.".".$conf->global->OSC_DB_TABLE_PREFIX."products_description as p"; + $sql .= " FROM ".$conf->global->OSC_DB_NAME.".".$conf->global->OSC_DB_TABLE_PREFIX."reviews as r, ".$conf->global->OSC_DB_NAME.".".$conf->global->OSC_DB_TABLE_PREFIX."reviews_description as d"; + $sql .= " ,".$conf->global->OSC_DB_NAME.".".$conf->global->OSC_DB_TABLE_PREFIX."products_description as p"; - $sql .= " WHERE r.reviews_id = d.reviews_id AND r.products_id=p.products_id"; - $sql .= " AND p.language_id = ".$conf->global->OSC_LANGUAGE_ID. " AND d.languages_id=".$conf->global->OSC_LANGUAGE_ID; - $sql .= " AND r.reviews_id=$id"; + $sql .= " WHERE r.reviews_id = d.reviews_id AND r.products_id=p.products_id"; + $sql .= " AND p.language_id = ".$conf->global->OSC_LANGUAGE_ID. " AND d.languages_id=".$conf->global->OSC_LANGUAGE_ID; + $sql .= " AND r.reviews_id=$id"; - $result = $this->db->query($sql) ; + $result = $this->db->query($sql) ; - if ( $result ) - { - $result = $this->db->fetch_array(); + if ( $result ) + { + $result = $this->db->fetch_array($result); - $this->id = $result["reviews_id"]; - $this->product_name = stripslashes($result["products_name"]); - $this->text = stripslashes($result["reviews_text"]); + $this->id = $result["reviews_id"]; + $this->product_name = stripslashes($result["products_name"]); + $this->text = stripslashes($result["reviews_text"]); - $this->db->free(); - } - else - { - print $this->db->error(); - print "

$sql"; - } + $this->db->free($result); + } + else + { + print $this->db->error(); + print "

$sql"; + } - return $result; - } + return $result; + } } ?> diff --git a/htdocs/boutique/promotion/class/promotion.class.php b/htdocs/boutique/promotion/class/promotion.class.php index 474547705a1..0d340c5d379 100644 --- a/htdocs/boutique/promotion/class/promotion.class.php +++ b/htdocs/boutique/promotion/class/promotion.class.php @@ -19,162 +19,161 @@ */ class Promotion { - var $db ; + var $db ; - var $id ; - var $parent_id ; - var $oscid ; - var $ref; - var $titre; - var $description; - var $price ; - var $status ; + var $id ; + var $parent_id ; + var $oscid ; + var $ref; + var $titre; + var $description; + var $price ; + var $status ; - function Promotion($DB, $id=0) { - $this->db = $DB; - $this->id = $id ; - } - /* - * - * - * - */ - function create($user, $pid, $percent) { - global $conf; + function Promotion($DB, $id=0) { + $this->db = $DB; + $this->id = $id ; + } + /* + * + * + * + */ + function create($user, $pid, $percent) { + global $conf; - $sql = "SELECT products_price "; - $sql .= " FROM ".$conf->global->OSC_DB_NAME.".".$conf->global->OSC_DB_TABLE_PREFIX."products as p"; - $sql .= " WHERE p.products_id = $pid"; + $sql = "SELECT products_price "; + $sql .= " FROM ".$conf->global->OSC_DB_NAME.".".$conf->global->OSC_DB_TABLE_PREFIX."products as p"; + $sql .= " WHERE p.products_id = ".$pid; - $result = $this->db->query($sql) ; + $result = $this->db->query($sql); + if ( $result ) + { + $result = $this->db->fetch_array($result); + $this->price_init = $result["products_price"]; + } - if ( $result ) - { - $result = $this->db->fetch_array(); - $this->price_init = $result["products_price"]; - } + $newprice = 0.95 * $this->price_init; - $newprice = 0.95 * $this->price_init; + $date_exp = "2003-05-01"; - $date_exp = "2003-05-01"; + $sql = "INSERT INTO ".$conf->global->OSC_DB_NAME.".".$conf->global->OSC_DB_TABLE_PREFIX."specials "; + $sql .= " (products_id, specials_new_products_price, specials_date_added, specials_last_modified, expires_date, date_status_change, status) "; + $sql .= " VALUES ($pid, $newprice, ".$this->db->idate(mktime()).", NULL, '$date_exp',NULL,1)"; - $sql = "INSERT INTO ".$conf->global->OSC_DB_NAME.".".$conf->global->OSC_DB_TABLE_PREFIX."specials "; - $sql .= " (products_id, specials_new_products_price, specials_date_added, specials_last_modified, expires_date, date_status_change, status) "; - $sql .= " VALUES ($pid, $newprice, ".$this->db->idate(mktime()).", NULL, '$date_exp',NULL,1)"; + if ($this->db->query($sql) ) + { + $id = $this->db->last_insert_id(OSC_DB_NAME.".specials"); - if ($this->db->query($sql) ) - { - $id = $this->db->last_insert_id(OSC_DB_NAME.".specials"); + return $id; + } + else + { + print $this->db->error() . ' in ' . $sql; + } + } + /* + * + * + * + */ + function update($id, $user) + { + $sql = "UPDATE ".MAIN_DB_PREFIX."album "; + $sql .= " SET title = '" . trim($this->titre) ."'"; + $sql .= ",description = '" . trim($this->description) ."'"; - return $id; - } - else - { - print $this->db->error() . ' in ' . $sql; - } - } - /* - * - * - * - */ - function update($id, $user) - { - $sql = "UPDATE ".MAIN_DB_PREFIX."album "; - $sql .= " SET title = '" . trim($this->titre) ."'"; - $sql .= ",description = '" . trim($this->description) ."'"; + $sql .= " WHERE rowid = " . $id; - $sql .= " WHERE rowid = " . $id; + if ( $this->db->query($sql) ) { + return 1; + } else { + print $this->db->error() . ' in ' . $sql; + } + } + /* + * + * + * + */ + function set_active($id) + { + global $conf; - if ( $this->db->query($sql) ) { - return 1; - } else { - print $this->db->error() . ' in ' . $sql; - } - } - /* - * - * - * - */ - function set_active($id) - { - global $conf; + $sql = "UPDATE ".$conf->global->OSC_DB_NAME.".".$conf->global->OSC_DB_TABLE_PREFIX."specials"; + $sql .= " SET status = 1"; - $sql = "UPDATE ".$conf->global->OSC_DB_NAME.".".$conf->global->OSC_DB_TABLE_PREFIX."specials"; - $sql .= " SET status = 1"; + $sql .= " WHERE products_id = " . $id; - $sql .= " WHERE products_id = " . $id; + if ( $this->db->query($sql) ) { + return 1; + } else { + print $this->db->error() . ' in ' . $sql; + } + } + /* + * + */ + function set_inactive($id) + { + global $conf; - if ( $this->db->query($sql) ) { - return 1; - } else { - print $this->db->error() . ' in ' . $sql; - } - } - /* - * - */ - function set_inactive($id) - { - global $conf; + $sql = "UPDATE ".$conf->global->OSC_DB_NAME.".".$conf->global->OSC_DB_TABLE_PREFIX."specials"; + $sql .= " SET status = 0"; - $sql = "UPDATE ".$conf->global->OSC_DB_NAME.".".$conf->global->OSC_DB_TABLE_PREFIX."specials"; - $sql .= " SET status = 0"; + $sql .= " WHERE products_id = " . $id; - $sql .= " WHERE products_id = " . $id; + if ( $this->db->query($sql) ) { + return 1; + } else { + print $this->db->error() . ' in ' . $sql; + } + } + /* + * + * + * + */ + function fetch ($id) { + global $conf; - if ( $this->db->query($sql) ) { - return 1; - } else { - print $this->db->error() . ' in ' . $sql; - } - } - /* - * - * - * - */ - function fetch ($id) { - global $conf; + $sql = "SELECT c.categories_id, cd.categories_name, c.parent_id"; + $sql .= " FROM ".$conf->global->OSC_DB_NAME.".".$conf->global->OSC_DB_TABLE_PREFIX."categories as c,".$conf->global->OSC_DB_NAME.".".$conf->global->OSC_DB_TABLE_PREFIX."categories_description as cd"; + $sql .= " WHERE c.categories_id = cd.categories_id AND cd.language_id = ".$conf->global->OSC_LANGUAGE_ID; + $sql .= " AND c.categories_id = ".$id; + $result = $this->db->query($sql) ; - $sql = "SELECT c.categories_id, cd.categories_name, c.parent_id"; - $sql .= " FROM ".$conf->global->OSC_DB_NAME.".".$conf->global->OSC_DB_TABLE_PREFIX."categories as c,".$conf->global->OSC_DB_NAME.".".$conf->global->OSC_DB_TABLE_PREFIX."categories_description as cd"; - $sql .= " WHERE c.categories_id = cd.categories_id AND cd.language_id = ".$conf->global->OSC_LANGUAGE_ID; - $sql .= " AND c.categories_id = $id"; - $result = $this->db->query($sql) ; + if ( $result ) { + $result = $this->db->fetch_array($result); - if ( $result ) { - $result = $this->db->fetch_array(); + $this->id = $result["categories_id"]; + $this->parent_id = $result["parent_id"]; + $this->name = $result["categories_name"]; + $this->titre = $result["title"]; + $this->description = $result["description"]; + $this->oscid = $result["osc_id"]; + } + $this->db->free($result); - $this->id = $result["categories_id"]; - $this->parent_id = $result["parent_id"]; - $this->name = $result["categories_name"]; - $this->titre = $result["title"]; - $this->description = $result["description"]; - $this->oscid = $result["osc_id"]; - } - $this->db->free(); - - return $result; - } + return $result; + } - /* - * - * - */ - function delete($user) { + /* + * + * + */ + function delete($user) { - global $conf; + global $conf; - $sql = "DELETE FROM ".$conf->global->OSC_DB_NAME.".".$conf->global->OSC_DB_TABLE_PREFIX."products WHERE products_id = $idosc "; + $sql = "DELETE FROM ".$conf->global->OSC_DB_NAME.".".$conf->global->OSC_DB_TABLE_PREFIX."products WHERE products_id = $idosc "; - $sql = "DELETE FROM ".$conf->global->OSC_DB_NAME.".".$conf->global->OSC_DB_TABLE_PREFIX."products_to_categories WHERE products_id = $idosc"; + $sql = "DELETE FROM ".$conf->global->OSC_DB_NAME.".".$conf->global->OSC_DB_TABLE_PREFIX."products_to_categories WHERE products_id = $idosc"; - $sql = "DELETE FROM ".$conf->global->OSC_DB_NAME.".".$conf->global->OSC_DB_TABLE_PREFIX."products_description WHERE products_id = $idosc"; + $sql = "DELETE FROM ".$conf->global->OSC_DB_NAME.".".$conf->global->OSC_DB_TABLE_PREFIX."products_description WHERE products_id = $idosc"; - } + } } diff --git a/htdocs/compta/export/modules/compta.export.poivre.class.php b/htdocs/compta/export/modules/compta.export.poivre.class.php index 72f5ce4cf43..2ac80399fa9 100644 --- a/htdocs/compta/export/modules/compta.export.poivre.class.php +++ b/htdocs/compta/export/modules/compta.export.poivre.class.php @@ -21,349 +21,349 @@ */ /** - \file htdocs/compta/export/modules/compta.export.poivre.class.php - \ingroup compta - \brief Modele d'export compta poivre, export au format tableur - \remarks Ce fichier doit etre utilise comme un exemple, il est specifique a une utilisation particuliere - \version $Revision$ -*/ + \file htdocs/compta/export/modules/compta.export.poivre.class.php + \ingroup compta + \brief Modele d'export compta poivre, export au format tableur + \remarks Ce fichier doit etre utilise comme un exemple, il est specifique a une utilisation particuliere + \version $Revision$ + */ require_once(PHP_WRITEEXCEL_PATH."/class.writeexcel_workbook.inc.php"); require_once(PHP_WRITEEXCEL_PATH."/class.writeexcel_worksheet.inc.php"); /** - \class ComptaExportPoivre - \brief Classe permettant les exports comptables au format tableur -*/ + \class ComptaExportPoivre + \brief Classe permettant les exports comptables au format tableur + */ class ComptaExportPoivre extends ComptaExport { - var $db; - var $user; + var $db; + var $user; - /** - \brief Constructeur de la class - \param DB Object de base de donnees - \param USER Object utilisateur - */ - function ComptaExportPoivre ($DB, $USER) - { - $this->db = $DB; - $this->user = $USER; - } + /** + \brief Constructeur de la class + \param DB Object de base de donnees + \param USER Object utilisateur + */ + function ComptaExportPoivre ($DB, $USER) + { + $this->db = $DB; + $this->user = $USER; + } - /** - * Agregation des lignes de facture - */ - function Agregate($line_in) - { - dol_syslog("ComptaExportPoivre::Agregate"); - dol_syslog("ComptaExportPoivre::Agregate " . sizeof($line_in) . " lignes en entrees"); - $i = 0; - $j = 0; - $n = sizeof($line_in); + /** + * Agregation des lignes de facture + */ + function Agregate($line_in) + { + dol_syslog("ComptaExportPoivre::Agregate"); + dol_syslog("ComptaExportPoivre::Agregate " . sizeof($line_in) . " lignes en entrees"); + $i = 0; + $j = 0; + $n = sizeof($line_in); - // On commence par la ligne 0 + // On commence par la ligne 0 - $this->line_out[$j] = $line_in[$i]; + $this->line_out[$j] = $line_in[$i]; - //print "$j ".$this->line_out[$j][8] . "
"; + //print "$j ".$this->line_out[$j][8] . "
"; - for ( $i = 1 ; $i < $n ; $i++) - { - // On agrege les lignes avec le meme code comptable + for ( $i = 1 ; $i < $n ; $i++) + { + // On agrege les lignes avec le meme code comptable - if ( ($line_in[$i][1] == $line_in[$i-1][1]) && ($line_in[$i][4] == $line_in[$i-1][4]) ) + if ( ($line_in[$i][1] == $line_in[$i-1][1]) && ($line_in[$i][4] == $line_in[$i-1][4]) ) { - $this->line_out[$j][8] = ($this->line_out[$j][8] + $line_in[$i][8]); + $this->line_out[$j][8] = ($this->line_out[$j][8] + $line_in[$i][8]); } - else + else { - $j++; - $this->line_out[$j] = $line_in[$i]; + $j++; + $this->line_out[$j] = $line_in[$i]; } - } + } - dol_syslog("ComptaExportPoivre::Agregate " . sizeof($this->line_out) . " lignes en sorties"); + dol_syslog("ComptaExportPoivre::Agregate " . sizeof($this->line_out) . " lignes en sorties"); - return 0; - } + return 0; + } - /** - * - */ - function Export($dir, $linec, $linep, $id=0) - { - $error = 0; + /** + * + */ + function Export($dir, $linec, $linep, $id=0) + { + $error = 0; - dol_syslog("ComptaExportPoivre::Export"); - dol_syslog("ComptaExportPoivre::Export " . sizeof($linec) . " lignes en entrees"); + dol_syslog("ComptaExportPoivre::Export"); + dol_syslog("ComptaExportPoivre::Export " . sizeof($linec) . " lignes en entrees"); - $this->Agregate($linec); + $this->Agregate($linec); - $this->db->begin(); + $this->db->begin(); - if ($id == 0) - { - $dt = strftime('EC%y%m', time()); + if ($id == 0) + { + $dt = strftime('EC%y%m', time()); - $sql = "SELECT count(ref) FROM ".MAIN_DB_PREFIX."export_compta"; - $sql .= " WHERE ref like '$dt%'"; + $sql = "SELECT count(ref) FROM ".MAIN_DB_PREFIX."export_compta"; + $sql .= " WHERE ref like '".$dt."%'"; - if ($this->db->query($sql)) + $resql=$this->db->query($sql); + if ($resql) + { + $row = $this->db->fetch_row($resql); + $cc = $row[0]; + } + else + { + $error++; + dol_syslog("ComptaExportPoivre::Export Erreur Select"); + } + + + if (!$error) + { + $this->ref = $dt . substr("000".$cc, -2); + + $sql = "INSERT INTO ".MAIN_DB_PREFIX."export_compta (ref, date_export, fk_user)"; + $sql .= " VALUES ('".$this->ref."', ".$this->db->idate(mktime()).",".$this->user->id.")"; + + if ($this->db->query($sql)) + { + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."export_compta"); + } + else + { + $error++; + dol_syslog("ComptaExportPoivre::Export Erreur INSERT"); + } + } + } + else + { + $this->id = $id; + + $sql = "SELECT ref FROM ".MAIN_DB_PREFIX."export_compta"; + $sql .= " WHERE rowid = ".$this->id; + + $resql = $this->db->query($sql); + if ($resql) + { + $row = $this->db->fetch_row($resql); + $this->ref = $row[0]; + } + else + { + $error++; + dol_syslog("ComptaExportPoivre::Export Erreur Select"); + } + } + + + if (!$error) + { + dol_syslog("ComptaExportPoivre::Export ref : ".$this->ref); + + $fxname = $dir . "/".$this->ref.".xls"; + + $workbook = new writeexcel_workbook($fxname); + + $page = &$workbook->addworksheet('Export'); + + $page->set_column(0,0,8); // A + $page->set_column(1,1,6); // B + $page->set_column(2,2,9); // C + $page->set_column(3,3,14); // D + $page->set_column(4,4,44); // E + $page->set_column(5,5,9); // F Numero de piece + $page->set_column(6,6,8); // G + + + // Pour les factures + + // A 0 Date Operation 040604 pour 4 juin 2004 + // B 1 VE -> ventilation + // C 2 code Compte general + // D 3 code client + // E 4 Intitul + // F 5 Numero de piece + // G 7 Montant + // H 8 Type operation D pour Debit ou C pour Credit + // I Date d'echeance, = a la date d'operation si pas d'echeance + // J EUR pour Monnaie en Euros + + // Pour les paiements + + $i = 0; + $j = 0; + $n = sizeof($this->line_out); + + $oldfacture = 0; + + for ( $i = 0 ; $i < $n ; $i++) { - $row = $this->db->fetch_row(); - $cc = $row[0]; - } - else - { - $error++; - dol_syslog("ComptaExportPoivre::Export Erreur Select"); + if ( $oldfacture <> $this->line_out[$i][1]) + { + // Ligne client + $page->write_string($j, 0, strftime("%d%m%y",$this->line_out[$i][0])); + $page->write_string($j, 1, "VI"); + $page->write_string($j, 2, "41100000"); + $page->write_string($j, 3, stripslashes($this->line_out[$i][2])); + $page->write_string($j, 4, stripslashes($this->line_out[$i][3])." Facture"); + $page->write_string($j, 5, $this->line_out[$i][5]); // Numero de facture + $page->write($j, 6, price2num($this->line_out[$i][7])); + $page->write_string($j, 7, 'D' ); // D pour debit + $page->write_string($j, 8, strftime("%d%m%y",$this->line_out[$i][0])); + + $j++; + + // Ligne TVA + $page->write_string($j, 0, strftime("%d%m%y",$this->line_out[$i][0])); + $page->write_string($j, 1, "VI"); + $page->write_string($j, 2, '4457119'); + + $page->write_string($j, 4, stripslashes($this->line_out[$i][3])." Facture"); + $page->write_string($j, 5, $this->line_out[$i][5]); // Numero de facture + $page->write($j, 6, price2num($this->line_out[$i][6])); // Montant de TVA + $page->write_string($j, 7, 'C'); // C pour credit + $page->write_string($j, 8, strftime("%d%m%y",$this->line_out[$i][0])); + + $oldfacture = $this->line_out[$i][1]; + $j++; + } + + $page->write_string($j, 0, strftime("%d%m%y",$this->line_out[$i][0])); + $page->write_string($j, 1, 'VI'); + $page->write_string($j, 2, $this->line_out[$i][4]); // Code Comptable + $page->write_string($j, 4, $this->line_out[$i][3]." Facture"); + $page->write_string($j, 5, $this->line_out[$i][5]); + $page->write($j, 6, price2num(round($this->line_out[$i][8], 2))); + $page->write_string($j, 7, 'C'); // C pour credit + $page->write_string($j, 8, strftime("%d%m%y",$this->line_out[$i][0])); + + $j++; } - - if (!$error) + // Tag des lignes de factures + $n = sizeof($linec); + for ( $i = 0 ; $i < $n ; $i++) { - $this->ref = $dt . substr("000".$cc, -2); + $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet"; + $sql .= " SET fk_export_compta=".$this->id; + $sql .= " WHERE rowid = ".$linec[$i][10]; - $sql = "INSERT INTO ".MAIN_DB_PREFIX."export_compta (ref, date_export, fk_user)"; - $sql .= " VALUES ('".$this->ref."', ".$this->db->idate(mktime()).",".$this->user->id.")"; - - if ($this->db->query($sql)) - { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."export_compta"); - } - else - { - $error++; - dol_syslog("ComptaExportPoivre::Export Erreur INSERT"); - } - } - } - else - { - $this->id = $id; - - $sql = "SELECT ref FROM ".MAIN_DB_PREFIX."export_compta"; - $sql .= " WHERE rowid = ".$this->id; - - $resql = $this->db->query($sql); - - if ($resql) - { - $row = $this->db->fetch_row($resql); - $this->ref = $row[0]; - } - else - { - $error++; - dol_syslog("ComptaExportPoivre::Export Erreur Select"); - } - } - - - if (!$error) - { - dol_syslog("ComptaExportPoivre::Export ref : ".$this->ref); - - $fxname = $dir . "/".$this->ref.".xls"; - - $workbook = new writeexcel_workbook($fxname); - - $page = &$workbook->addworksheet('Export'); - - $page->set_column(0,0,8); // A - $page->set_column(1,1,6); // B - $page->set_column(2,2,9); // C - $page->set_column(3,3,14); // D - $page->set_column(4,4,44); // E - $page->set_column(5,5,9); // F Numero de piece - $page->set_column(6,6,8); // G - - - // Pour les factures - - // A 0 Date Operation 040604 pour 4 juin 2004 - // B 1 VE -> ventilation - // C 2 code Compte general - // D 3 code client - // E 4 Intitul - // F 5 Numero de piece - // G 7 Montant - // H 8 Type operation D pour Debit ou C pour Credit - // I Date d'echeance, = a la date d'operation si pas d'echeance - // J EUR pour Monnaie en Euros - - // Pour les paiements - - $i = 0; - $j = 0; - $n = sizeof($this->line_out); - - $oldfacture = 0; - - for ( $i = 0 ; $i < $n ; $i++) - { - if ( $oldfacture <> $this->line_out[$i][1]) - { - // Ligne client - $page->write_string($j, 0, strftime("%d%m%y",$this->line_out[$i][0])); - $page->write_string($j, 1, "VI"); - $page->write_string($j, 2, "41100000"); - $page->write_string($j, 3, stripslashes($this->line_out[$i][2])); - $page->write_string($j, 4, stripslashes($this->line_out[$i][3])." Facture"); - $page->write_string($j, 5, $this->line_out[$i][5]); // Numero de facture - $page->write($j, 6, price2num($this->line_out[$i][7])); - $page->write_string($j, 7, 'D' ); // D pour debit - $page->write_string($j, 8, strftime("%d%m%y",$this->line_out[$i][0])); - - $j++; - - // Ligne TVA - $page->write_string($j, 0, strftime("%d%m%y",$this->line_out[$i][0])); - $page->write_string($j, 1, "VI"); - $page->write_string($j, 2, '4457119'); - - $page->write_string($j, 4, stripslashes($this->line_out[$i][3])." Facture"); - $page->write_string($j, 5, $this->line_out[$i][5]); // Numero de facture - $page->write($j, 6, price2num($this->line_out[$i][6])); // Montant de TVA - $page->write_string($j, 7, 'C'); // C pour credit - $page->write_string($j, 8, strftime("%d%m%y",$this->line_out[$i][0])); - - $oldfacture = $this->line_out[$i][1]; - $j++; - } - - $page->write_string($j, 0, strftime("%d%m%y",$this->line_out[$i][0])); - $page->write_string($j, 1, 'VI'); - $page->write_string($j, 2, $this->line_out[$i][4]); // Code Comptable - $page->write_string($j, 4, $this->line_out[$i][3]." Facture"); - $page->write_string($j, 5, $this->line_out[$i][5]); - $page->write($j, 6, price2num(round($this->line_out[$i][8], 2))); - $page->write_string($j, 7, 'C'); // C pour credit - $page->write_string($j, 8, strftime("%d%m%y",$this->line_out[$i][0])); - - $j++; + if (!$this->db->query($sql)) + { + $error++; + } } - // Tag des lignes de factures - $n = sizeof($linec); - for ( $i = 0 ; $i < $n ; $i++) + // Pour les paiements + + // A Date Operation 040604 pour 4 juin 2004 + // B CE -> caisse d'epargne + // C code Compte general + // D code client + // E Intitul + // F Numero de piece + // G Montant + // H Type operation D pour Debit ou C pour Credit + // I Date d'echeance, = a la date d'operation si pas d'echeance + // J EUR pour Monnaie en Euros + + $i = 0; + //$j = 0; + $n = sizeof($linep); + + $oldfacture = 0; + + for ( $i = 0 ; $i < $n ; $i++) { - $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet"; - $sql .= " SET fk_export_compta=".$this->id; - $sql .= " WHERE rowid = ".$linec[$i][10]; + /* + * En cas de rejet ou paiement en negatif on inverse debit et credit + * + * + */ + if ($linep[$i][5] >= 0) + { + $debit = "D"; + $credit = "C"; + } + else + { + $debit = "C"; + $credit = "D"; - if (!$this->db->query($sql)) - { - $error++; - } - } - - // Pour les paiements - - // A Date Operation 040604 pour 4 juin 2004 - // B CE -> caisse d'epargne - // C code Compte general - // D code client - // E Intitul - // F Numero de piece - // G Montant - // H Type operation D pour Debit ou C pour Credit - // I Date d'echeance, = a la date d'operation si pas d'echeance - // J EUR pour Monnaie en Euros - - $i = 0; - //$j = 0; - $n = sizeof($linep); - - $oldfacture = 0; - - for ( $i = 0 ; $i < $n ; $i++) - { - /* - * En cas de rejet ou paiement en negatif on inverse debit et credit - * - * - */ - if ($linep[$i][5] >= 0) - { - $debit = "D"; - $credit = "C"; - } - else - { - $debit = "C"; - $credit = "D"; - - if ($linep[$i][6] == 'Prelevement') - { + if ($linep[$i][6] == 'Prelevement') + { $linep[$i][6] = 'Rejet Prelevement'; - } - } + } + } - $page->write_string($j,0, strftime("%d%m%y",$linep[$i][0])); - $page->write_string($j,1, 'CE'); + $page->write_string($j,0, strftime("%d%m%y",$linep[$i][0])); + $page->write_string($j,1, 'CE'); - $page->write_string($j,2, '5122000'); + $page->write_string($j,2, '5122000'); - if ($linep[$i][6] == 'Prelevement') - { - $linep[$i][6] = 'Prelevement'; - } + if ($linep[$i][6] == 'Prelevement') + { + $linep[$i][6] = 'Prelevement'; + } - $page->write_string($j,4, stripslashes($linep[$i][3])." ".stripslashes($linep[$i][6])); // - $page->write_string($j,5, $linep[$i][7]); // Numero de facture + $page->write_string($j,4, stripslashes($linep[$i][3])." ".stripslashes($linep[$i][6])); // + $page->write_string($j,5, $linep[$i][7]); // Numero de facture - $page->write($j,6, price2num(round(abs($linep[$i][5]), 2))); // Montant de la ligne - $page->write_string($j,7,$debit); - $page->write_string($j,8, strftime("%d%m%y",$linep[$i][0])); + $page->write($j,6, price2num(round(abs($linep[$i][5]), 2))); // Montant de la ligne + $page->write_string($j,7,$debit); + $page->write_string($j,8, strftime("%d%m%y",$linep[$i][0])); - $j++; + $j++; - $page->write_string($j,0, strftime("%d%m%y",$linep[$i][0])); - $page->write_string($j,1, 'CE'); + $page->write_string($j,0, strftime("%d%m%y",$linep[$i][0])); + $page->write_string($j,1, 'CE'); - $page->write_string($j,2, '41100000'); - $page->write_string($j,3, $linep[$i][2]); - $page->write_string($j,4, stripslashes($linep[$i][3])." ".stripslashes($linep[$i][6])); // - $page->write_string($j,5, $linep[$i][7]); // Numero de facture - $page->write($j,6, price2num(round(abs($linep[$i][5]), 2))); // Montant de la ligne - $page->write_string($j,7, $credit); - $page->write_string($j,8, strftime("%d%m%y",$linep[$i][0])); + $page->write_string($j,2, '41100000'); + $page->write_string($j,3, $linep[$i][2]); + $page->write_string($j,4, stripslashes($linep[$i][3])." ".stripslashes($linep[$i][6])); // + $page->write_string($j,5, $linep[$i][7]); // Numero de facture + $page->write($j,6, price2num(round(abs($linep[$i][5]), 2))); // Montant de la ligne + $page->write_string($j,7, $credit); + $page->write_string($j,8, strftime("%d%m%y",$linep[$i][0])); - $j++; + $j++; } - $workbook->close(); + $workbook->close(); - // Tag des lignes de factures - $n = sizeof($linep); - for ( $i = 0 ; $i < $n ; $i++) + // Tag des lignes de factures + $n = sizeof($linep); + for ( $i = 0 ; $i < $n ; $i++) { - $sql = "UPDATE ".MAIN_DB_PREFIX."paiement"; - $sql .= " SET fk_export_compta=".$this->id; - $sql .= " WHERE rowid = ".$linep[$i][1]; + $sql = "UPDATE ".MAIN_DB_PREFIX."paiement"; + $sql .= " SET fk_export_compta=".$this->id; + $sql .= " WHERE rowid = ".$linep[$i][1]; - if (!$this->db->query($sql)) - { - $error++; - } + if (!$this->db->query($sql)) + { + $error++; + } } - } + } - if (!$error) - { - $this->db->commit(); - dol_syslog("ComptaExportPoivre::Export COMMIT"); - } - else - { - $this->db->rollback(); - dol_syslog("ComptaExportPoivre::Export ROLLBACK"); - } + if (!$error) + { + $this->db->commit(); + dol_syslog("ComptaExportPoivre::Export COMMIT"); + } + else + { + $this->db->rollback(); + dol_syslog("ComptaExportPoivre::Export ROLLBACK"); + } - return 0; - } + return 0; + } } diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 0ff4eb26d26..283e272d397 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -2631,9 +2631,10 @@ class Facture extends CommonObject $sql.= ' WHERE fk_facture = '.$this->id; $sql.= ' AND traite = 0'; - if ( $this->db->query( $sql) ) + $resql=$this->db->query($sql); + if ($resql) { - $row = $this->db->fetch_row(); + $row = $this->db->fetch_row($resql); if ($row[0] == 0) { $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'prelevement_facture_demande'; @@ -2645,7 +2646,7 @@ class Facture extends CommonObject $sql .= ",'".$soc->bank_account->code_guichet."'"; $sql .= ",'".$soc->bank_account->number."'"; $sql .= ",'".$soc->bank_account->cle_rib."')"; - if ( $this->db->query( $sql) ) + if ( $this->db->query($sql)) { return 1; } diff --git a/htdocs/compta/prelevement/fiche-stat.php b/htdocs/compta/prelevement/fiche-stat.php index 0c312e8bbff..e378c033f61 100644 --- a/htdocs/compta/prelevement/fiche-stat.php +++ b/htdocs/compta/prelevement/fiche-stat.php @@ -47,9 +47,9 @@ $h++; if ($conf->use_preview_tabs) { - $head[$h][0] = DOL_URL_ROOT.'/compta/prelevement/bon.php?id='.$_GET["id"]; - $head[$h][1] = $langs->trans("Preview"); - $h++; + $head[$h][0] = DOL_URL_ROOT.'/compta/prelevement/bon.php?id='.$_GET["id"]; + $head[$h][1] = $langs->trans("Preview"); + $h++; } $head[$h][0] = DOL_URL_ROOT.'/compta/prelevement/lignes.php?id='.$_GET["id"]; @@ -73,86 +73,87 @@ $prev_id = $_GET["id"]; if ($prev_id) { - $bon = new BonPrelevement($db,""); + $bon = new BonPrelevement($db,""); - if ($bon->fetch($_GET["id"]) == 0) - { - dol_fiche_head($head, $hselected, $langs->trans("WithdrawalReceipt")); - - print ''; - - print ''; - - print '
'.$langs->trans("Ref").''.$bon->getNomUrl(1).'
'; - - print ''; - } - else - { - print "Erreur"; - } - - /* - * Stats - * - */ - $sql = "SELECT sum(pl.amount), pl.statut"; - $sql.= " FROM ".MAIN_DB_PREFIX."prelevement_lignes as pl"; - $sql.= " WHERE pl.fk_prelevement_bons = ".$prev_id; - $sql.= " GROUP BY pl.statut"; - - if ($db->query($sql)) - { - $num = $db->num_rows(); - $i = 0; - - print"\n\n"; - print ''; - print ''; - print ''; - - $var=false; - - while ($i < $num) + if ($bon->fetch($_GET["id"]) == 0) { - $row = $db->fetch_row(); + dol_fiche_head($head, $hselected, $langs->trans("WithdrawalReceipt")); - print "'; - - print "\n"; - - $var=!$var; - $i++; + print ''; + } + else + { + print "Erreur"; } - print "
'.$langs->trans("Status").''.$langs->trans("Amount").'%
"; + print ''; - if ($row[1] == 2) - { - print $langs->trans("StatusCredited"); - } - elseif ($row[1] == 3) - { - print $langs->trans("StatusRefused"); - } - elseif ($row[1] == 1) - { - print $langs->trans("StatusWaiting"); - } - else print $langs->trans("StatusUnknown"); + print ''; - print '
'.$langs->trans("Ref").''.$bon->getNomUrl(1).'
'; - print price($row[0]); + print '
'; - print '
'; - print round($row[0]/$bon->amount*100,2)." %"; - print '
"; - $db->free(); - } - else - { - print $db->error() . ' ' . $sql; - } + /* + * Stats + * + */ + $sql = "SELECT sum(pl.amount), pl.statut"; + $sql.= " FROM ".MAIN_DB_PREFIX."prelevement_lignes as pl"; + $sql.= " WHERE pl.fk_prelevement_bons = ".$prev_id; + $sql.= " GROUP BY pl.statut"; + + $resql=$db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + $i = 0; + + print"\n\n"; + print ''; + print ''; + print ''; + + $var=false; + + while ($i < $num) + { + $row = $db->fetch_row($resql); + + print "'; + + print "\n"; + + $var=!$var; + $i++; + } + + print "
'.$langs->trans("Status").''.$langs->trans("Amount").'%
"; + + if ($row[1] == 2) + { + print $langs->trans("StatusCredited"); + } + elseif ($row[1] == 3) + { + print $langs->trans("StatusRefused"); + } + elseif ($row[1] == 1) + { + print $langs->trans("StatusWaiting"); + } + else print $langs->trans("StatusUnknown"); + + print ''; + print price($row[0]); + + print ''; + print round($row[0]/$bon->amount*100,2)." %"; + print '
"; + $db->free($resql); + } + else + { + print $db->error() . ' ' . $sql; + } } $db->close(); diff --git a/htdocs/lib/databases/mssql.lib.php b/htdocs/lib/databases/mssql.lib.php index d5bb1ae9e92..17316766e02 100644 --- a/htdocs/lib/databases/mssql.lib.php +++ b/htdocs/lib/databases/mssql.lib.php @@ -426,7 +426,7 @@ class DoliDb \param resultset Curseur de la requete voulue \return array */ - function fetch_row($resultset=0) + function fetch_row($resultset) { // Si le resultset n'est pas fourni, on prend le dernier utilise sur cette connexion if (! is_resource($resultset)) { $resultset=$this->results; } @@ -439,7 +439,7 @@ class DoliDb \param resultset Curseur de la requete voulue \return int Nombre de lignes */ - function num_rows($resultset=0) + function num_rows($resultset) { // Si le resultset n'est pas fourni, on prend le dernier utilise sur cette connexion if (! is_resource($resultset)) { $resultset=$this->results; } diff --git a/htdocs/lib/databases/mysql.lib.php b/htdocs/lib/databases/mysql.lib.php index 999d1ff6fc7..ae9290486a7 100644 --- a/htdocs/lib/databases/mysql.lib.php +++ b/htdocs/lib/databases/mysql.lib.php @@ -421,7 +421,7 @@ class DoliDb * \param resultset Curseur de la requete voulue * \return array */ - function fetch_row($resultset=0) + function fetch_row($resultset) { // Si le resultset n'est pas fourni, on prend le dernier utilise sur cette connexion if (! is_resource($resultset)) { $resultset=$this->results; } @@ -434,7 +434,7 @@ class DoliDb * \param resultset Curseur de la requete voulue * \return int Nombre de lignes */ - function num_rows($resultset=0) + function num_rows($resultset) { // Si le resultset n'est pas fourni, on prend le dernier utilise sur cette connexion if (! is_resource($resultset)) { $resultset=$this->results; } diff --git a/htdocs/lib/databases/mysqli.lib.php b/htdocs/lib/databases/mysqli.lib.php index 1b3aef915f4..e1387478369 100644 --- a/htdocs/lib/databases/mysqli.lib.php +++ b/htdocs/lib/databases/mysqli.lib.php @@ -426,7 +426,7 @@ class DoliDb * \param resultset Curseur de la requete voulue * \return array */ - function fetch_row($resultset=0) + function fetch_row($resultset) { // Si le resultset n'est pas fourni, on prend le dernier utilise sur cette connexion if (! is_bool($resultset)) @@ -447,7 +447,7 @@ class DoliDb * \param resultset Curseur de la requete voulue * \return int Nombre de lignes */ - function num_rows($resultset=0) + function num_rows($resultset) { // Si le resultset n'est pas fourni, on prend le dernier utilise sur cette connexion if (! is_object($resultset)) { $resultset=$this->results; } diff --git a/htdocs/lib/databases/pgsql.lib.php b/htdocs/lib/databases/pgsql.lib.php index 4c2081fa7a8..87cc48bb55c 100644 --- a/htdocs/lib/databases/pgsql.lib.php +++ b/htdocs/lib/databases/pgsql.lib.php @@ -515,7 +515,7 @@ class DoliDb * \param resultset Curseur de la requete voulue * \return array */ - function fetch_row($resultset=0) + function fetch_row($resultset) { // Si le resultset n'est pas fourni, on prend le dernier utilise sur cette connexion if (! is_resource($resultset)) { $resultset=$this->results; } @@ -528,7 +528,7 @@ class DoliDb * \param resultset Curseur de la requete voulue * \return int Nombre de lignes */ - function num_rows($resultset=0) + function num_rows($resultset) { // Si le resultset n'est pas fourni, on prend le dernier utilise sur cette connexion if (! is_resource($resultset)) { $resultset=$this->results; }