From 2ce0531d01dbf82b0c5ea949a4eba5f60897a97f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 5 Jun 2010 15:45:32 +0000 Subject: [PATCH] Move files to right repository --- scripts/books/droits-editeurs.php | 317 ---------------------------- scripts/books/droits-nouveautes.php | 181 ---------------- 2 files changed, 498 deletions(-) delete mode 100644 scripts/books/droits-editeurs.php delete mode 100644 scripts/books/droits-nouveautes.php diff --git a/scripts/books/droits-editeurs.php b/scripts/books/droits-editeurs.php deleted file mode 100644 index a96b049a99e..00000000000 --- a/scripts/books/droits-editeurs.php +++ /dev/null @@ -1,317 +0,0 @@ -#!/usr/bin/php - - * Copyright (C) 2009 Laurent Destailleur - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -/** - * \file scripts/books/droits-editeurs.php - * \ingroup editeurs - * \brief Script de generation des courriers pour les editeurs - * \version $Id$ - */ - -require_once("../../htdocs/master.inc.php"); -require_once(FPDF_PATH.'fpdf.php'); -require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php"); -require_once(DOL_DOCUMENT_ROOT."/product/canvas/livre/product.livre.class.php"); - -$error = 0; -$year = strftime("%Y", time()); - -// -$sql = "SELECT s.rowid as socid, s.nom"; -$sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; -//$sql .= " , ".MAIN_DB_PREFIX."categorie_fournisseur as cf"; -$sql .= " WHERE s.fournisseur = 1 "; -//$sql .= " AND s.rowid = cf.fk_societe"; -//$sql .= " AND cf.fk_categorie = 2"; - -$resql=$db->query($sql); -if ($resql) -{ - while ($obj = $db->fetch_object($resql) ) - { - $id = $obj->socid; - - dol_syslog("droits-editeurs.php id:$id", LOG_DEBUG ); - - $coupdf = new pdf_courrier_editeur($db, $langs); - $coupdf->write($id, $year); - } -} -else -{ - print $db->error(); - print $sql; -} - -class pdf_courrier_editeur -{ - - /** - \brief Constructeur - \param db Handler acces base de donnees - */ - function pdf_courrier_editeur ($db=0, $langs) - { - $this->langs = $langs; - - $this->db = $db; - - // Dimension page pour format A4 - $this->type = 'pdf'; - $this->page_largeur = 210; - $this->page_hauteur = 297; - $this->format = array($this->page_largeur,$this->page_hauteur); - $this->marge_gauche=10; - $this->marge_droite=10; - $this->marge_haute=10; - $this->marge_basse=10; - - } - - /** - \brief Fonction generant la fiche d'intervention sur le disque - \param id id de la fiche intervention a generer - \return int 1=ok, 0=ko - */ - function write($id, $year) - { - $soc = new Societe($this->db); - $soc->fetch($id); - - $fichref = $year; - - $dir = $conf->societe->dir_output."/courrier/" . get_exdir($id); - $file = $dir . $fichref . ".pdf"; - - if (! file_exists($dir)) - { - if (create_exdir($dir) < 0) - { - $this->error=$this->langs->trans("ErrorCanNotCreateDir",$dir); - return 0; - } - } - - if (file_exists($dir)) - { - // Initialisation document vierge - $pdf=new FPDF('P','mm',$this->format); - $pdf->Open(); - - $books = array(); - $year_data = $year - 1; - - // On recupere donnees du mail - $sql = "SELECT p.rowid, p.label, pc.taux, pc.quantite"; - $sql .= " FROM ".MAIN_DB_PREFIX."facture as f"; - $sql .= " , ".MAIN_DB_PREFIX."facturedet as fd"; - $sql .= " , ".MAIN_DB_PREFIX."product as p"; - $sql .= " , ".MAIN_DB_PREFIX."product_cnv_livre as pl"; - $sql .= " , ".MAIN_DB_PREFIX."product_cnv_livre_contrat as pc"; - - $sql .= " WHERE fd.fk_facture = f.rowid"; - $sql .= " AND fd.fk_product = p.rowid"; - $sql .= " AND p.canvas = 'livre'"; - $sql .= " AND p.rowid = pl.rowid"; - $sql .= " AND pl.fk_contrat = pc.rowid"; - $sql .= " AND year (f.datef) <= ".($year_data); - $sql .= " GROUP BY p.rowid"; - - $resql=$this->db->query($sql); - if ($resql) - { - $i = 0; - while ($obj = $this->db->fetch_object($resql) ) - { - $id = $obj->socid; - $books[$i]['title'] = $obj->label; - $books[$i]['id'] = $obj->rowid; - $books[$i]['taux'] = $obj->taux; - $books[$i]['qty'] = $obj->quantite; - - $i++; - } - $this->db->free($resql); - } - else - { - print $this->db->error(); - print "$sql\n"; - } - - foreach($books as $ref => $value) - { - $livre = new ProductLivre($this->db); - $livre->FetchCanvas($value['id']); - - $pdf->AddPage(); - $qtycontrat = $value['qty']; - /* - * Adresse - */ - - - // Client destinataire - $posy=42; - $pdf->SetTextColor(0,0,0); - $pdf->SetFont('Arial','',8); - $pdf->SetXY(102,$posy-5); - - // Nom client - $pdf->SetXY(102,$posy+3); - $pdf->SetFont('Arial','B',11); - $pdf->MultiCell(106,4, $soc->nom, 0, 'L'); - - // Caracteristiques client - $carac_client=$soc->address; - $carac_client.="\n".$soc->cp . " " . $soc->ville."\n"; - $carac_client.=$soc->pays."\n"; - - $pdf->SetFont('Arial','',9); - $pdf->SetXY(102,$posy+8); - $pdf->MultiCell(86,4, $carac_client); - /* - * - * - */ - $pdf->SetTextColor(0,0,0); - $pdf->SetFont('Arial','',10); - - $pdf->SetXY(10,100); - - $pdf->MultiCell(190,5,"Je vous prie de trouver ci-dessous le récapitulatif des ventes du titre cité pour la période du 1er janvier au 31 décembre $year_data."); - - $pdf->SetXY(10,120); - $pdf->MultiCell(25,5,"Nom du titre : "); - $pdf->SetFont('Arial','B',10); - $pdf->SetXY(35,120); - $pdf->MultiCell(140,5,$value['title']); - - $pdf->SetFont('Arial','',10); - $pdf->SetXY(10,140); - $pdf->MultiCell(46,5,"Quantité signée au contrat : "); - - $pdf->SetFont('Arial','B',10); - $pdf->SetXY(56,140); - $pdf->MultiCell(14,5,$qtycontrat,0,'R'); - - $sql = "SELECT p.label, sum(fd.qty), date_format(f.datef,'%Y')"; - $sql .= " FROM ".MAIN_DB_PREFIX."facture as f"; - $sql .= " , ".MAIN_DB_PREFIX."facturedet as fd"; - $sql .= " , ".MAIN_DB_PREFIX."product as p"; - $sql .= " WHERE fd.fk_facture = f.rowid"; - $sql .= " AND p.rowid = '".$value['id']."'"; - $sql .= " AND fd.fk_product = p.rowid"; - $sql .= " AND p.canvas = 'livre'"; - $sql .= " GROUP BY p.rowid, date_format(f.datef,'%Y') ORDER BY date_format(f.datef,'%Y') ASC"; - - $resql=$this->db->query($sql); - - $qtysell = 0; - - if ($resql) - { - $i = 0; - while ($row = $this->db->fetch_row($resql) ) - { - $i++; - - $pdf->SetFont('Arial','',10); - $pdf->SetXY(10,140 + ($i * 8) ); - $pdf->MultiCell(44,5,"Quantité vendue en ".$row[2]." : ",0); - $pdf->SetFont('Arial','B',10); - $pdf->SetXY(54,140 + ($i * 8) ); - $pdf->MultiCell(16,5,$row[1],0,'R'); - - $qtysell += $row[1]; - - } - $this->db->free($resql); - } - else - { - print $this->db->error(); - } - - - $pdf->SetFont('Arial','',10); - $pdf->SetXY(100,140 + ($i * 8) ); - $pdf->MultiCell(15,5,"Solde : ",0); - $pdf->SetFont('Arial','B',10); - $pdf->SetXY(115,140 + ($i * 8) ); - $pdf->MultiCell(16,5,($qtycontrat - $qtysell),0,'R'); - - $i++; - $pdf->SetFont('Arial','',10); - $pdf->SetXY(10,140 + ($i * 10) ); - $pdf->MultiCell(50,5,"Taux des droits d'auteurs : ",0); - $pdf->SetFont('Arial','B',10); - $pdf->SetXY(60,140 + ($i * 10) ); - $pdf->MultiCell(16,5, $value['taux']." %",0,'R'); - - $i++; - $pdf->SetFont('Arial','',10); - $pdf->SetXY(10,140 + ($i * 10) ); - $pdf->MultiCell(50,5,"Prix de vente des livres HT : ",0); - $pdf->SetFont('Arial','B',10); - $pdf->SetXY(60,140 + ($i * 10) ); - $pdf->MultiCell(16,5, sprintf("%.2f",$livre->price),0,'R'); - - $i++; - $pdf->SetFont('Arial','',10); - $pdf->SetXY(10,140 + ($i * 10) ); - $pdf->MultiCell(50,5,"Prix de vente des livres TTC : ",0); - $pdf->SetFont('Arial','B',10); - $pdf->SetXY(60,140 + ($i * 10) ); - $pdf->MultiCell(16,5, sprintf("%.2f",$livre->price_ttc),0,'R'); - - $i++; - $pdf->SetFont('Arial','',10); - $pdf->SetXY(10,150 + ($i * 10) ); - $pdf->MultiCell(80,5,"Reste à devoir sur les droits pour l'année ".($year-1)." : ",0); - $pdf->SetFont('Arial','B',10); - $pdf->SetXY(90,140 + ($i * 10) ); - $pdf->MultiCell(16,5, $pu_ttc,0,'R'); - - $i++; - $pdf->SetFont('Arial','',10); - $pdf->SetXY(10,150 + ($i * 10) + 20); - $pdf->MultiCell(190,5,"Nous restons à votre entière disposition pour de plus amples renseignements dont vous pouvez avoir besoin et vous remercions de la confiance que vous nous avez accordée."); - - - } - - $pdf->Close(); - - $pdf->Output($file); - dol_syslog("droits-editeurs.php write $file", LOG_DEBUG ); - return 0; - } - else - { - $this->error=$this->langs->trans("ErrorCanNotCreateDir",$dir); - return -6; - } - } - - -} - -?> diff --git a/scripts/books/droits-nouveautes.php b/scripts/books/droits-nouveautes.php deleted file mode 100644 index ec77cc33b5b..00000000000 --- a/scripts/books/droits-nouveautes.php +++ /dev/null @@ -1,181 +0,0 @@ -#!/usr/bin/php - - * Copyright (C) 2009 Laurent Destailleur - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -/** - * \file scripts/books/droits-editeurs.php - * \ingroup editeurs - * \brief Script de generation des courriers pour les editeurs - * \version $Id$ - */ - -require_once("../../htdocs/master.inc.php"); -require_once(PHP_WRITEEXCEL_PATH."/class.writeexcel_workbook.inc.php"); -require_once(PHP_WRITEEXCEL_PATH."/class.writeexcel_worksheet.inc.php"); - -$error = 0; - -$year = strftime('%Y', time()); - -$fname = "/tmp/droits-nouveautes-".$year.".xls"; - -$workbook = new writeexcel_workbook($fname); - -$page = &$workbook->addworksheet("Droits nouveautes ".$year); - -$fcent =& $workbook->addformat(array( - 'align' => 'center', - 'border' => 1 - )); - -$fdroit =& $workbook->addformat(array( - 'bg_color' => 0x0A, - 'color' => 0x09, - 'bold' => 1, - 'align' => 'center', - 'border' => 1 - )); - -$fvent =& $workbook->addformat(array( - 'bg_color' => 0x35, - 'bold' => 1, - 'align' => 'center' - )); - - - -$fdroits=& $workbook->addformat(array( - 'bg_color' => 24, - 'bold' => 1, - 'align' => 'center', - 'border' => 1 - )); - -$page->set_column(0,0,10); // A -$page->set_column(1,1,12); // B -$page->set_column(2,2,15); // C -$page->set_column(3,3,9); // C -$page->set_column(4,8,8); - - -$sql = "SELECT fd.fk_product, sum(fd.qty), date_format(f.datef,'%c')>6"; -$sql .= " FROM ".MAIN_DB_PREFIX."facturedet as fd,".MAIN_DB_PREFIX."facture as f"; -$sql .= " WHERE fd.fk_facture=f.rowid"; -$sql .= " AND date_format(f.datef,'%Y') ='".$year."'"; -$sql .= " GROUP BY fd.fk_product, date_format(f.datef,'%c')>6"; -$ventes = array(); -$resql=$db->query($sql); -if ($resql) -{ - while ($row = $db->fetch_row($resql)) - { - $ventes[$row[0]][$row[2]] = $row[1]; - } - $db->free($resql); -} -else -{ - print "Error "; -} - - - - -$sql = "SELECT p.rowid, p.ref,p.label, p.price_ttc as pv, s.nom as fournisseur"; -$sql .= ",c.quantite as droits, c.taux"; -$sql .= " FROM ".MAIN_DB_PREFIX."product as p"; -$sql .= ", ".MAIN_DB_PREFIX."product_cnv_livre as pl"; -$sql .= ", ".MAIN_DB_PREFIX."product_cnv_livre_contrat as c"; - -$sql .= ", ".MAIN_DB_PREFIX."product_fournisseur as pf"; -$sql .= ", ".MAIN_DB_PREFIX."societe as s"; - -$sql .= " WHERE p.rowid = pl.rowid"; -$sql .= " AND pf.fk_product = p.rowid AND s.rowid = pf.fk_soc"; -$sql .= " AND p.rowid = c.fk_cnv_livre"; -$sql .= " AND p.canvas = 'livre'"; -$sql .= " ORDER BY p.rowid ASC"; - -if ($db->query($sql)) -{ - $i = 0; - $j = 1; - - $page->write_string(0, 0, "Ref", $fcent); - $page->write_string(0, 1, "Titre", $fcent); - $page->write_string(0, 2, "Nom"); - $page->write_string(0, 3, "Droits", $fdroit); - $page->write_string(0, 4, "Taux", $fcent); - $page->write_string(0, 5, "P.V.", $fcent); - - $page->write_string(0, 7, "Droits\nverses", $fcent); - $page->write_string(0, 8, "Soit\npar livre", $fcent); - - $page->write_string(0, 9, "Ventes\n1er sem", $fvent); - $page->write_string(0, 10, "Ventes\n2eme sem", $fvent); - $page->write_string(0, 11, "Total\nVentes", $fvent); - $page->write_string(0, 12, "Solde", $fcent); - - $page->write_string(0,13,"Droits\na payer",$fdroits); - $page->write_string(0,14,"Droits payes\ndavance",$fdroits); - - while ($obj = $db->fetch_object()) - { - $k = $j+1; - - $page->write_string($j, 0, $obj->ref, $fcent); - $page->write_string($j, 1, stripslashes($obj->label), $fcent); - $page->write_string($j, 2, stripslashes($obj->fournisseur), $fcent); - $page->write($j, 3, $obj->droits, $fdroit); - $page->write($j, 4, $obj->taux, $fcent); - $page->write($j, 5, $obj->pv, $fcent); - - $page->write_formula($j,6,"=F$k/1.055",$fcent); - $page->write_formula($j,7,"=F$k*E$k*D$k/100",$fcent); - $page->write_formula($j,8,"=H$k/D$k",$fcent); - - $page->write_number($j,9, $ventes[$obj->rowid][0],$fvent); - $page->write_number($j,10, $ventes[$obj->rowid][1],$fvent); - - $page->write_formula($j,11,"=J$k+K$k",$fvent); - $page->write_formula($j,12,"=L$k-D$k",$fcent); - - if ($obj->droits < ($ventes[$obj->rowid][0]+$ventes[$obj->rowid][1])) - { - $page->write_formula($j,13,"=M$k*I$k",$fdroits); - $page->write_string($j,14,'',$fdroits); - } - else - { - $page->write_string($j,13,'',$fdroits); - $page->write_formula($j,14,"=M$k*I$k",$fdroits); - } - - $j++; - $i++; - - } -} -else -{ - print "Error "; -} - -$workbook->close(); -?>