From aa593d4af087fcde5a95a071cf76408681b952ae Mon Sep 17 00:00:00 2001 From: Rodolphe Quiedeville Date: Sun, 2 Feb 2003 15:01:56 +0000 Subject: [PATCH] *** empty log message *** --- htdocs/compta/facture.php3 | 182 +++++++++++++++++++++++++++++--- htdocs/compta/fiche.php3 | 4 +- htdocs/compta/index.php3 | 51 ++++++++- htdocs/facture.class.php3 | 11 +- htdocs/fourn/facture/index.php3 | 35 +++--- htdocs/societe.class.php3 | 95 ++++++++++++++--- 6 files changed, 320 insertions(+), 58 deletions(-) diff --git a/htdocs/compta/facture.php3 b/htdocs/compta/facture.php3 index eafc7cdfd24..709c2da6b94 100644 --- a/htdocs/compta/facture.php3 +++ b/htdocs/compta/facture.php3 @@ -21,6 +21,7 @@ */ require("./pre.inc.php3"); require("../facture.class.php3"); +require("../lib/CMailFile.class.php3"); llxHeader(); @@ -127,6 +128,58 @@ if ($action == 'add') $action = ''; } +/* + * + */ + +if ($action == 'send') +{ + $fac = new Facture($db,"",$facid); + $fac->fetch($facid); + + $soc = new Societe($db, $fac->socidp); + + $file = $conf->facture->outputdir . "/" . $fac->ref . "/" . $fac->ref . ".pdf"; + + if (file_exists($file)) + { + + $sendto = $soc->contact_get_email($HTTP_POST_VARS["destinataire"]); + + if (strlen($sendto)) + { + + $subject = "Facture $fac->ref"; + $message = "Veuillez trouver ci-joint la facture $fac->ref\n\nCordialement\n\n"; + $filename = "$fac->ref.pdf"; + + $replyto = $HTTP_POST_VARS["replytoname"] . " <".$HTTP_POST_VARS["replytomail"] .">"; + + $mailfile = new CMailFile($subject,$sendto,$replyto,$message,$file, "application/pdf", $filename); + + if ( $mailfile->sendfile() ) + { + + $sql = "INSERT INTO actioncomm (datea,fk_action,fk_soc,note,fk_facture) VALUES (now(), 9 ,$fac->socidp ,'Envoyée à $sendndto',$fac->id);"; + + if (! $db->query($sql) ) + { + print $db->error(); + print "

$sql

"; + } + } + else + { + print "!! erreur d'envoi
$sendto
$replyto
$filename"; + } + } + else + { + print "Can't get email $sendto"; + } + } +} + /* * * Mode creation @@ -255,6 +308,8 @@ else print $db->error(); } + $soc = new Societe($db, $obj->socidp); + $author = new User($db); $author->id = $obj->fk_user_author; $author->fetch(); @@ -357,9 +412,9 @@ else echo ''; print ""; - print ""; - print ''; - print ''; + print ''; + print ''; + print ''; print "\n"; $var=True; @@ -375,6 +430,10 @@ else print ''; print ''; } + else + { + print ''; + } print ""; if ($action == 'editline' && $rowid == $objp->rowid) @@ -412,7 +471,7 @@ else print ""; echo '
DateQuantitéMontant  DescriptionQuantitéMontant  
deledit  
'; print ""; - print ""; + print ""; print ""; print ""; print "\n"; @@ -437,7 +496,11 @@ else { print ""; } - else + elseif ($obj->statut == 1 && $resteapayer > 0) + { + print ""; + } + else { print ""; } @@ -475,16 +538,16 @@ else * */ print "
"; - print "
DateDescriptionQuantitéMontant
[Supprimer][Envoyer]-
"; - print "Documents générés
"; - print ""; + print "
"; + print_titre("Documents générés"); + print ''; $file = $conf->facture->outputdir . "/" . $obj->facnumber . "/" . $obj->facnumber . ".pdf"; if (file_exists($file)) { - print ""; + print ""; print ''; print ''; print ''; @@ -495,17 +558,65 @@ else if (file_exists($file)) { - print ""; + print ""; print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; } - print ''; + print ''; - print "
Propale PDF
Facture PDFfacnumber."/".$obj->facnumber.'.pdf">'.$obj->facnumber.'.pdf'.filesize($file). ' bytes'.strftime("%d %b %Y %H:%M:%S",filemtime($file)).'
Propale Postscript
Facture Postscriptfacnumber."/".$obj->facnumber.'.ps">'.$obj->facnumber.'.ps'.filesize($file). ' bytes'.strftime("%d %b %Y %H:%M:%S",filemtime($file)).'
'.filesize($file). ' bytes'.strftime("%d %b %Y %H:%M:%S",filemtime($file)).'
(liste...)
(liste...)
\n
"; + print "
\n"; + print ""; + print ''; + print_titre("Actions"); + /* + * Liste des actions + * + */ + $sql = "SELECT ".$db->pdate("a.datea")." as da, a.note"; + $sql .= " FROM actioncomm as a WHERE a.fk_soc = $obj->socidp AND a.fk_action = 9 AND a.fk_facture = $facid"; + + $result = $db->query($sql); + if ($result) + { + $num = $db->num_rows(); + if ($num) + { + $i = 0; $total = 0; + print ''; + print ""; + print ""; + print ""; + print "\n"; + + $var=True; + while ($i < $num) + { + $objp = $db->fetch_object( $i); + $var=!$var; + print ""; + print "\n"; + print ''; + print ""; + $i++; + } + print "
DateAction
".strftime("%d %B %Y",$objp->da)."'.stripslashes($objp->note).'
"; + } + } + else + { + print $db->error(); + } + + /* + * + * + */ + print ""; + print ""; /* * Generation de la facture @@ -513,7 +624,7 @@ else */ if ($action == 'pdf') { - print "
Génération de la facture
"; + print "
Génération de la facture
";
 	$command = "export DBI_DSN=\"dbi:mysql:dbname=".$conf->db->name."\" ";
 	$command .= " ; ./texfacture.pl --html -vv --facture=$facid --pdf --output=".$conf->facture->outputdir;
 	$command .= " --templates=".$conf->facture->templatesdir;
@@ -521,8 +632,47 @@ else
 	$output = system($command);
 	print "

command :
$command
"; //print "

output :
$output
"; + print "

"; } + /* + * + * + */ + if ($action == 'presend') + { + $replytoname = "R. Quiedeville"; + $from_name = $replytoname; + $replytomail = "rq@quiedeville.org"; + $from_mail = $replytomail; + + print "\n"; + print "\n"; + print "\n"; + + print "

Envoyer la facture par mail"; + print ""; + print ''; + print ""; + print ""; + print ""; + print ""; + + print "
Destinataire'; + $form = new Form($db); + + $form->select_array("destinataire",$soc->contact_email_array()); + + print 'email\">
Expéditeur$from_name$from_mail
Reply-to$replytoname$replytomail
"; + print ""; + print ""; + } + + /* + * + * + */ + /* * Propales diff --git a/htdocs/compta/fiche.php3 b/htdocs/compta/fiche.php3 index 790361d0c8b..c22850092df 100644 --- a/htdocs/compta/fiche.php3 +++ b/htdocs/compta/fiche.php3 @@ -306,7 +306,7 @@ if ($socid > 0) { print "Prénom Nom"; print 'PosteTél'; print "FaxEmail"; - print "idp&action=addcontact\">Ajouter"; + print "idp&action=addcontact\">Ajouter"; $sql = "SELECT p.idp, p.name, p.firstname, p.poste, p.phone, p.fax, p.email, p.note FROM socpeople as p WHERE p.fk_soc = $objsoc->idp ORDER by p.datec"; $result = $db->query($sql); @@ -331,7 +331,7 @@ if ($socid > 0) { print ''.$obj->phone.' '; print ''.$obj->fax.' '; print ''.$obj->email.' '; - print "idp&action=editcontact&contactid=$obj->idp\">Modifier"; + print "idp&action=editcontact&contactid=$obj->idp\">Modifier"; print "\n"; $i++; $tag = !$tag; diff --git a/htdocs/compta/index.php3 b/htdocs/compta/index.php3 index 241163ed2ed..744202e25d0 100644 --- a/htdocs/compta/index.php3 +++ b/htdocs/compta/index.php3 @@ -52,12 +52,15 @@ if ($action == 'del_bookmark') { $sql = "DELETE FROM llx_bookmark WHERE rowid=$bid"; $result = $db->query($sql); } - +/* + * + * + */ print_titre(translate("Espace compta")); print ''; -print ''; +if ( $db->query($sql) ) +{ + $num = $db->num_rows(); + if ($num) + { + print '
'; +print '
'; /* * Charges a payer * @@ -163,7 +166,7 @@ if ( $db->query($sql) ) { * * */ -print ''; +print ''; $result = 0; @@ -187,9 +190,49 @@ if ( $result ) { } else { print $db->error(); } +/* + * + * + */ +/* + * Charges a payer + * + */ +$sql = "SELECT ff.amount, ff.libelle"; +$sql .= " FROM llx_facture_fourn as ff"; +$sql .= " WHERE ff.paye=0"; -print '
'; + print ''; + print ''; + print "\n"; + $i = 0; + + while ($i < $num) + { + $obj = $db->fetch_object( $i); + $var = !$var; + print ""; + print ''; + print ''; + print ''; + $i++; + } + print '
Charges à payer
'.$obj->libelle.''.price($obj->amount).'

'; + } +} +else +{ + print $db->error(); +} + +print ' '; print ''; diff --git a/htdocs/facture.class.php3 b/htdocs/facture.class.php3 index d512a37ccaf..34a400420b5 100644 --- a/htdocs/facture.class.php3 +++ b/htdocs/facture.class.php3 @@ -110,7 +110,7 @@ class Facture { Function fetch($rowid) { - $sql = "SELECT ref,price,remise,".$this->db->pdate(datep)."as dp FROM llx_facture WHERE rowid=$rowid;"; + $sql = "SELECT fk_soc,facnumber,amount,remise,".$this->db->pdate(datef)."as df FROM llx_facture WHERE rowid=$rowid;"; if ($this->db->query($sql) ) { @@ -118,11 +118,12 @@ class Facture { { $obj = $this->db->fetch_object(0); - $this->id = $rowid; - $this->datep = $obj->dp; - $this->ref = $obj->ref; - $this->price = $obj->price; + $this->id = $rowid; + $this->datep = $obj->dp; + $this->ref = $obj->facnumber; + $this->remise = $obj->remise; + $this->socidp = $obj->fk_soc; $this->db->free(); } diff --git a/htdocs/fourn/facture/index.php3 b/htdocs/fourn/facture/index.php3 index e4163e33c80..42babfe10df 100644 --- a/htdocs/fourn/facture/index.php3 +++ b/htdocs/fourn/facture/index.php3 @@ -25,12 +25,6 @@ require("../../contact.class.php3"); llxHeader(); $db = new Db(); -if ($sortorder == "") { - $sortorder="ASC"; -} -if ($sortfield == "") { - $sortfield="nom"; -} if ($action == 'note') { $sql = "UPDATE societe SET note='$note' WHERE idp=$socid"; @@ -116,11 +110,21 @@ if ($socid > 0) { */ print_barre_liste("Liste des factures fournisseurs", $page, $PHP_SELF); + if ($sortorder == "") + { + $sortorder="ASC"; + } + if ($sortfield == "") + { + $sortfield="fac.paye"; + } + + $sql = "SELECT s.idp as socid, s.nom, ".$db->pdate("s.datec")." as datec, ".$db->pdate("s.datea")." as datea, s.prefix_comm, fac.amount, fac.paye, fac.libelle, ".$db->pdate("fac.datef")." as datef, fac.rowid as facid"; $sql .= " FROM societe as s, llx_facture_fourn as fac "; $sql .= " WHERE fac.fk_soc = s.idp"; - // $sql .= " ORDER BY $sortfield $sortorder " . $db->plimit( $limit, $offset); + $sql .= " ORDER BY $sortfield $sortorder " . $db->plimit( $limit, $offset); $result = $db->query($sql); @@ -128,17 +132,18 @@ if ($socid > 0) { $num = $db->num_rows(); $i = 0; - if ($sortorder == "DESC") { - $sortorder="ASC"; - } else { - $sortorder="DESC"; - } + if ($sortorder == "DESC") + { + $sortorder="ASC"; + } else { + $sortorder="DESC"; + } print "

"; print ''; print ""; - print ""; + print ''; + print ''; print "\n"; $var=True; while ($i < $num) { @@ -151,7 +156,7 @@ if ($socid > 0) { print "\n"; print ''; - print "\n"; + print ''; print "\n"; diff --git a/htdocs/societe.class.php3 b/htdocs/societe.class.php3 index f2d0226b8f4..636594bf49e 100644 --- a/htdocs/societe.class.php3 +++ b/htdocs/societe.class.php3 @@ -71,26 +71,27 @@ class Societe { * * */ - Function update($id) { + Function update($id) + { - $sql = "UPDATE societe "; - $sql .= " SET nom = '" . trim($this->nom) ."'"; - $sql .= ",address = '" . trim($this->adresse) ."'"; - $sql .= ",cp = '" . trim($this->cp) ."'"; - $sql .= ",ville = '" . trim($this->ville) ."'"; - $sql .= ",tel = '" . trim($this->tel) ."'"; - $sql .= ",fax = '" . trim($this->fax) ."'"; - $sql .= ",url = '" . trim($this->url) ."'"; - $sql .= ",siren = '" . trim($this->siren) ."'"; - $sql .= ",client = " . $this->client ; - $sql .= ",fournisseur = " . $this->fournisseur ; - $sql .= " WHERE idp = " . $id .";"; - - if (! $this->db->query($sql)) + $sql = "UPDATE societe "; + $sql .= " SET nom = '" . trim($this->nom) ."'"; + $sql .= ",address = '" . trim($this->adresse) ."'"; + $sql .= ",cp = '" . trim($this->cp) ."'"; + $sql .= ",ville = '" . trim($this->ville) ."'"; + $sql .= ",tel = '" . trim($this->tel) ."'"; + $sql .= ",fax = '" . trim($this->fax) ."'"; + $sql .= ",url = '" . trim($this->url) ."'"; + $sql .= ",siren = '" . trim($this->siren) ."'"; + $sql .= ",client = " . $this->client ; + $sql .= ",fournisseur = " . $this->fournisseur ; + $sql .= " WHERE idp = " . $id .";"; + + if (! $this->db->query($sql)) { print $this->db->error(); } - } + } /* * * @@ -214,7 +215,69 @@ class Societe { $this->db->free(); } } + /* + * + * + */ + Function contact_email_array() + { + $contact_email = array(); + $sql = "SELECT idp, email, name, firstname FROM socpeople WHERE fk_soc = $this->id"; + + if ($this->db->query($sql) ) + { + $nump = $this->db->num_rows(); + + if ($nump) + { + $i = 0; + while ($i < $nump) + { + $obj = $this->db->fetch_object($i); + + $contact_email[$obj->idp] = "$obj->firstname $obj->name <$obj->email>"; + $i++; + } + } + return $contact_email; + } + else + { + print $this->db->error(); + } + + } + /* + * + * + */ + Function contact_get_email($rowid) + { + + $sql = "SELECT idp, email, name, firstname FROM socpeople WHERE idp = $rowid"; + + if ($this->db->query($sql) ) + { + $nump = $this->db->num_rows(); + + if ($nump) + { + + $obj = $this->db->fetch_object(0); + + $contact_email = "$obj->firstname $obj->name <$obj->email>"; + + } + return $contact_email; + } + else + { + print $this->db->error(); + print "

$rowid"; + } + + } }

Libelle"; print_liste_field_titre("Société",$PHP_SELF,"s.nom"); - print "Montant MontantPayé
socid\">$obj->nom'.price($obj->amount).'$obj->prefix_comm '.$yn[$obj->paye].'