[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpcompta-dev] r647 - in trunk/invoicing: . include
From: |
phpcompta-dev |
Subject: |
[Phpcompta-dev] r647 - in trunk/invoicing: . include |
Date: |
Mon, 6 Jan 2014 01:09:32 +0100 (CET) |
Author: danydb
Date: 2014-01-06 01:09:31 +0100 (Mon, 06 Jan 2014)
New Revision: 647
Modified:
trunk/invoicing/include/invoice_generate.inc.php
trunk/invoicing/include/invoice_send_mail.inc.php
trunk/invoicing/include/invoice_to_zip.inc.php
trunk/invoicing/include/invoicing.inc.php
trunk/invoicing/index.php
trunk/invoicing/raw.php
Log:
Add send by email and download zip
Modified: trunk/invoicing/include/invoice_generate.inc.php
===================================================================
--- trunk/invoicing/include/invoice_generate.inc.php 2014-01-05 21:28:43 UTC
(rev 646)
+++ trunk/invoicing/include/invoice_generate.inc.php 2014-01-06 00:09:31 UTC
(rev 647)
@@ -21,7 +21,8 @@
/**
* @file
- * @brief
+ * @brief regenerate all the invoice
* @param type $name Descriptionara
*/
+var_dump($_REQUEST);
?>
Modified: trunk/invoicing/include/invoice_send_mail.inc.php
===================================================================
--- trunk/invoicing/include/invoice_send_mail.inc.php 2014-01-05 21:28:43 UTC
(rev 646)
+++ trunk/invoicing/include/invoice_send_mail.inc.php 2014-01-06 00:09:31 UTC
(rev 647)
@@ -1,5 +1,4 @@
<?php
-
/*
* This file is part of PhpCompta.
*
@@ -23,5 +22,124 @@
* @file
* @brief
* @param type $name Descriptionara
+ @note
+ array
+ 'gDossier' => string '27' (length=2)
+ 'ac' => string 'EXT/INVOICING' (length=13)
+ 'plugin_code' => string 'INVOICING' (length=9)
+ 'sel_sale' =>
+ array
+ 0 => string '2871' (length=4)
+ 'document' => string '16' (length=2)
+ 'action' => string '3' (length=1)
+ 'pdf' => string 'on' (length=2)
+ 'email_from' => string 'address@hidden' (length=15)
+ 'email_subject' => string 'Facture' (length=7)
+ 'email_message' => string 'Message test ' (length=27)
+ 'copy' => string 'on' (length=2)
+ 'choice_sel' => string 'Exécuter' (length=9)
+
+ @endnote
*/
+require_once 'class_sendmail.php';
+
+$from = HtmlInput::default_value_get('email_from', 'null');
+$subject = HtmlInput::default_value_get('email_subject', 'null');
+$message = HtmlInput::default_value_get('email_message', 'null');
+$copy = HtmlInput::default_value_get('email_copy', 'null');
+$pdf = HtmlInput::default_value_get('pdf', 'null');
+
+
+$feedback = array();
+$dirname = tempnam($_ENV['TMP'], 'invoice');
+unlink($dirname);
+umask(0);
+mkdir($dirname);
+$cn->start();
+foreach ($_GET['sel_sale'] as $key => $value)
+{
+ $a_invoice = $cn->get_array("select jr_id,jr_pj_name,jr_pj,qs_client
+ from jrn join quant_sold on (jr_internal=qs_internal)
+ where jr_id = $1", array($value));
+ $invoice = $a_invoice[0];
+ $dest = new Fiche($cn, $invoice['qs_client']);
+ $dest_mail = $dest->strAttribut(ATTR_DEF_EMAIL);
+ $dest_name = $dest->strAttribut(ATTR_DEF_NAME);
+ $dest_qcode = $dest->strAttribut(ATTR_DEF_QUICKCODE);
+
+ /**
+ * Something to send
+ */
+ if ($invoice['jr_pj_name'] != "" && $invoice['jr_pj'] != "" && $dest_mail
!= "" && $dest_mail != NOTFOUND)
+ {
+ // -- send mail --//
+ $file = $dirname . '/' . $invoice['jr_pj_name'];
+ $cn->lo_export($invoice['jr_pj'], $file);
+ $filetosend = $file;
+ /*
+ * convert to PDF
+ */
+ if (GENERATE_PDF != "YES" && $pdf != 'null')
+ {
+ $feedback[] = _('Pas de conversion en PDF disponible');
+ continue;
+ }
+ if (GENERATE_PDF == 'YES' && $pdf == 'on')
+ {
+ // convert to PDF
+ $cn->lo_export($invoice['jr_pj'], $file);
+
+ // remove extension
+ $ext = strrpos($file, ".");
+ $filetosend = substr($file, 0, $ext);
+ $filetosend .=".pdf";
+
+ passthru(OFFICE . $file, $status);
+ if ($status == 1)
+ {
+ $feedback[] = "Cannot convert to PDF , email not sent for " .
+ $dest_mail . " qcode = " . $dest_qcode . " name = " .
$dest_name;
+ continue;
+ }
+ }
+ $sendmail = new Sendmail();
+ $sendmail->set_from($from);
+ $to = $dest_mail;
+
+ if ($copy != 'null')
+ {
+ $to = $dest_mail . ',' . $from;
+ }
+ $sendmail->mailto($from);
+ $sendmail->set_subject($subject);
+ $sendmail->set_message($message);
+ $ofile = new FileToSend($filetosend);
+ $sendmail->add_file($ofile);
+ $sendmail->compose();
+ try
+ {
+ $sendmail->send();
+ $feedback[] = _('Envoi facture ') . $invoice['jr_pj_name'] . _('
destinataire ') . $dest_qcode . " " . $dest_name . " " . $dest_mail;
+ } catch (Exception $e)
+ {
+ $feedback[] = _('Envoi echoué') . " $dest_qcode $dest_name
$dest_mail";
+ }
+ } else if ($invoice['jr_pj_name'] != "" || $invoice['jr_pj'] != "")
+ {
+ $feedback[] = _('Aucune pièce à envoyer') . " $dest_qcode $dest_name
$dest_mail";
+ } else if ($dest_mail == "")
+ {
+ $feedback[] = _('Aucune adresse email trouvée') . " $dest_qcode
$dest_name $dest_mail";
+ }
+}
?>
+<ol>
+ <?php foreach ($feedback as $line): ?>
+
+ <li>
+ <?php echo $line; ?>
+ </li>
+<?php endforeach; ?>
+</ol>
+
+
Modified: trunk/invoicing/include/invoice_to_zip.inc.php
===================================================================
--- trunk/invoicing/include/invoice_to_zip.inc.php 2014-01-05 21:28:43 UTC
(rev 646)
+++ trunk/invoicing/include/invoice_to_zip.inc.php 2014-01-06 00:09:31 UTC
(rev 647)
@@ -52,13 +52,12 @@
$res = $zip->open($zip_file, ZipArchive::CREATE);
if ($res != true)
{
- var_dump($res);
- exit();
+ die("Cannot create zip file");
}
$zip->add_recurse_folder($dirname . "/");
$zip->close();
//-- send the zip
-$link = http_build_query(array('gDossier' => Dossier::id(), 'ac' =>
$_REQUEST['ac'], 'plugin_code' => $_REQUEST['plugin_code'], 'file' =>
$zip_file));
+$link = http_build_query(array('gDossier' => Dossier::id(), 'ac' =>
$_REQUEST['ac'], 'plugin_code' => $_REQUEST['plugin_code'], 'file' =>
basename($zip_file)));
?>
<p>
<h2>
@@ -73,4 +72,6 @@
<?php endforeach; ?>
</ol>
</p>
-<a class="detail" style="display:inline;text-decoration: underline"
href="extension.raw.php?<?php echo $link; ?>"> <?php echo _('Télécharger le
fichier') ?></a>
\ No newline at end of file
+<p>
+<a class="button" style="display:inline;" href="extension.raw.php?<?php echo
$link; ?>"> <?php echo _('Télécharger le fichier') ?></a>
+</p>
\ No newline at end of file
Modified: trunk/invoicing/include/invoicing.inc.php
===================================================================
--- trunk/invoicing/include/invoicing.inc.php 2014-01-05 21:28:43 UTC (rev
646)
+++ trunk/invoicing/include/invoicing.inc.php 2014-01-06 00:09:31 UTC (rev
647)
@@ -60,7 +60,7 @@
// --- template Invoice to generate --- //
$document=new ISelect('document');
-$document->value=$cn->make_array('select md_id,md_name from document_modele
order by 2');
+$document->value=$cn->make_array("select md_id,md_name from document_modele
where md_affect='VEN' order by 2");
$document_to_send=new ISelect('format_document');
$document_to_send->value=array(
@@ -106,18 +106,22 @@
<input type="checkbox" name="pdf"> <?php echo
_('Conversion en PDF'); ?>
</p>
<p>
- <input type="checkbox" name="copy"> <?php echo _('Copie
envoyée à'); ?>
- <input type="text" name="email_copy" class="input_text">
+ <?php echo _('Email envoyé par'); ?> :
+ <input type="text" name="email_from" class="input_text">
</p>
+
<p>
<?php echo _('Sujet')?> :
<input type="text" name="email_subject" class="input_text">
</p>
<p>
<?php echo _('Message')?> :
- <textarea style="vertical-align: top;width:23%;height:10%"
name="message" class="input_text"> </textarea>
+ <textarea style="vertical-align: top;width:23%;height:10%"
name="email_message" class="input_text"> </textarea>
</p>
-
+ <p>
+ <input type="checkbox" name="copy"> <?php echo _("Envoyer
copie à l'expéditeur"); ?>
+
+ </p>
</div>
</li>
</ul>
Modified: trunk/invoicing/index.php
===================================================================
--- trunk/invoicing/index.php 2014-01-05 21:28:43 UTC (rev 646)
+++ trunk/invoicing/index.php 2014-01-06 00:09:31 UTC (rev 647)
@@ -39,5 +39,6 @@
require_once 'class_acc_ledger_sold.php';
require_once 'include/invoicing.inc.php';
require_once('class_zip_extended.php');
-
+require_once 'class_sendmail.php';
+require_once 'class_filetosend.php';
?>
Modified: trunk/invoicing/raw.php
===================================================================
--- trunk/invoicing/raw.php 2014-01-05 21:28:43 UTC (rev 646)
+++ trunk/invoicing/raw.php 2014-01-06 00:09:31 UTC (rev 647)
@@ -30,9 +30,11 @@
{
die ('No file asked');
}
-echo filesize($zip_file);
+
+$zip_file=$_ENV['TMP']."/".$zip_file;
+
header('Content-type: application/zip');
-header('Content-Disposition: attachment; filename="' . basename($file));
+header('Content-Disposition: attachment; filename="' . $file);
$h_file=fopen($zip_file,"r");
if ($h_file != true) {
die ('cannot open file');
---
PhpCompta est un logiciel de comptabilité libre en ligne (full web)
Projet opensource http://www.phpcompta.eu
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpcompta-dev] r647 - in trunk/invoicing: . include,
phpcompta-dev <=