phpcompta-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Phpcompta-dev] r720 - trunk/invoicing/include


From: phpcompta-dev
Subject: [Phpcompta-dev] r720 - trunk/invoicing/include
Date: Fri, 14 Mar 2014 17:56:30 +0100 (CET)

Author: danydb
Date: 2014-03-14 17:56:29 +0100 (Fri, 14 Mar 2014)
New Revision: 720

Added:
   trunk/invoicing/include/invoice_send_mail_input.inc.php
   trunk/invoicing/include/invoice_send_mail_route.inc.php
Modified:
   trunk/invoicing/include/invoice_send_mail.inc.php
   trunk/invoicing/include/invoicing.inc.php
Log:
Task #991 - Proposer d'ajouter la facture dans le suivi
Improve : second screen for sending mail + include in suivi

Modified: trunk/invoicing/include/invoice_send_mail.inc.php
===================================================================
--- trunk/invoicing/include/invoice_send_mail.inc.php   2014-03-12 16:47:17 UTC 
(rev 719)
+++ trunk/invoicing/include/invoice_send_mail.inc.php   2014-03-14 16:56:29 UTC 
(rev 720)
@@ -26,25 +26,48 @@
  * @param email_message text 
  * @param email_copy copy to sender
  * @param pdf convert to pdf
-   @endnote
+  @endnote
  */
 require_once 'class_sendmail.php';
+require_once 'class_follow_up.php';
+global $cn;
 
-$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', '-1');
-$pdf = HtmlInput::default_value_get('pdf', 'null');
-if ($from == "null") {
-    die (_("Désolé mais il faut donner l'email de celui qui envoie"));
+//----- Mail
+$from = HtmlInput::default_value_post('email_from', 'null');
+$subject = HtmlInput::default_value_post('email_subject', 'null');
+$message = HtmlInput::default_value_post('email_message', 'null');
+$copy = HtmlInput::default_value_post('email_copy', '-1');
+$pdf = HtmlInput::default_value_post('pdf', 'null');
+
+//-- Follow up
+$ag_timestamp = HtmlInput::default_value_post('ag_timestamp', date('d.m.Y'));
+$ag_title = HtmlInput::default_value_post('ag_title', _('Ajouté depuis 
plugin'));
+$ag_remind_date=HtmlInput::default_value_post('ag_remind_date','');
+$ag_dest=HtmlInput::default_value_post('ag_dest',1);
+
+if (isDate($ag_timestamp) == null)
+    $ag_timestamp = date('d.m.Y');
+
+if (trim($ag_title) == "")
+    $ag_title = _("Ajouté depuis plugin");
+
+if (isDate($ag_remind_date) == null) {
+    $ag_remind_date=null;
 }
-if ($subject == "null") {
-    die (_("Le sujet est obligatoire"));
+
+
+if ($from == "null")
+{
+    die(_("Désolé mais il faut donner l'email de celui qui envoie"));
 }
+if ($subject == "null")
+{
+    die(_("Le sujet est obligatoire"));
+}
 
-if ( $message=="null")
+if ($message == "null")
 {
-    $message=$subject;
+    $message = $subject;
 }
 $feedback = array();
 $dirname = tempnam($_ENV['TMP'], 'invoice');
@@ -104,15 +127,16 @@
 
         if ($copy != '-1')
         {
-            $dest_mail= $dest_mail . ',' . $from;
+            $dest_mail = $dest_mail . ',' . $from;
         }
         $sendmail->mailto($dest_mail);
         $sendmail->set_subject($subject);
-        
-        if (strlen(trim($message))==0) {
-            $message=$subject;
+
+        if (strlen(trim($message)) == 0)
+        {
+            $message = $subject;
         }
-        
+
         $sendmail->set_message($message);
         $ofile = new FileToSend($filetosend);
         $sendmail->add_file($ofile);
@@ -121,26 +145,45 @@
             $sendmail->compose();
             $sendmail->send();
             $feedback[] = _('Envoi facture ') . $invoice['jr_pj_name'] . _(' 
destinataire ') . $dest_qcode . " " . $dest_name . " " . $dest_mail;
+            /**
+             * Save into follow up
+             */
+            $action = new Follow_Up($cn);
+            $a_follow['ag_dest'] = $ag_dest;
+            $ag_comment =  _("Envoi facture") . " " . $invoice['jr_pj_name']." 
"._(' à ').$dest_mail.PHP_EOL.$message;
+            $a_follow['ag_comment']=$ag_comment;
+            $a_follow['ag_title']=$ag_title;
+            $a_follow['ag_timestamp']=$ag_timestamp;
+            $a_follow['ag_remind_date']=$ag_remind_date;
+            $a_follow['dt_id']=HtmlInput::default_value_post('dt_id',-1);
+            $action->fromArray($a_follow);
+
+            $action->f_id_dest = $invoice['qs_client'];
+            $action->qcode_dest = $dest_qcode;
+            $_POST['nb_item'] = 0;
+            $action->save();
+// return $fiche->strAttribut(ATTR_DEF_QUICKCODE) . ' inclus dans Suivi';
         } catch (Exception $e)
         {
-            $feedback[] = _('Envoi echoué') ." ".$e->getMessage(). " 
$dest_qcode $dest_name $dest_mail ";
+            $feedback[] = _('Envoi echoué') . " " . $e->getMessage() . " 
$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 == "" || $dest_mail == NOTFOUND )
+    } else if ($dest_mail == "" || $dest_mail == NOTFOUND)
     {
         $feedback[] = _('Aucune adresse email trouvée') . " $dest_qcode 
$dest_name $dest_mail";
     }
 }
+$cn->commit();
 ?>
 <ol>
-        <?php foreach ($feedback as $line): ?>
+    <?php foreach ($feedback as $line): ?>
 
         <li>
-        <?php echo $line; ?>
+            <?php echo $line; ?>
         </li>
-<?php endforeach; ?>
+    <?php endforeach; ?>
 </ol>
 
 

Added: trunk/invoicing/include/invoice_send_mail_input.inc.php
===================================================================
--- trunk/invoicing/include/invoice_send_mail_input.inc.php                     
        (rev 0)
+++ trunk/invoicing/include/invoice_send_mail_input.inc.php     2014-03-14 
16:56:29 UTC (rev 720)
@@ -0,0 +1,168 @@
+<?php
+/*
+ *   This file is part of NOALYSS.
+ *
+ *   NOALYSS 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.
+ *
+ *   NOALYSS 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 NOALYSS; if not, write to the Free Software
+ *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+// Copyright Author Dany De Bontridder address@hidden
+
+global $g_user;
+
+$titre = new IText('ag_title');
+
+// Profile in charged of the action
+$ag_dest = new ISelect();
+$ag_dest->name = "ag_dest";
+// select profile
+$aAg_dest = $cn->make_array("select  p_id as value, " .
+        "p_name as label " .
+        " from profile  "
+        . "where p_id in (select p_granted from "
+            . " user_sec_action_profile where ua_right='W' and p_id=" . 
$g_user->get_profile() . ") order by 2");
+$ag_dest->value = $aAg_dest;
+
+// -- Date
+$date = new IDate();
+$date->name = "ag_timestamp";
+$date->value = date('d.m.Y');
+
+// -- remind date
+$remind_date = new IDate();
+$remind_date->name = "ag_remind_date";
+$remind_date->value = "";
+
+// -- document
+$category = new ISelect('dt_id');
+$category->value = $cn->make_array("select dt_id,dt_value from document_type 
order by dt_value");
+$category->readOnly = false;
+
+//-- description
+$desc = new ITextArea();
+$desc->style = ' class="itextarea" style="width:80%;margin-left:0px"';
+$desc->name = "ag_comment";
+?>
+<form method="POST" id="sel_sale_frm" onsubmit="return verify_invoicing()">
+<?php
+echo HtmlInput::request_to_hidden(array('gDossier', 'ac', 
'plugin_code','action'));
+echo HtmlInput::request_to_hidden(array('sel_sale'));
+echo HtmlInput::hidden('sa', 'send');
+?>
+
+    <h2 class="note"><?php echo _('Envoi uniquement à ceux ayant une adresse 
email et une facture') ?> </h2>
+    <p>
+        <input type="checkbox" name="pdf"> <?php echo _('Conversion en PDF'); 
?>
+    </p>
+    <p>
+        <?php echo _('Email envoyé par'); ?> :
+        <input type="text" id="email_from" name="email_from" 
class="input_text">
+        <span class="notice" id="email_from_span"></span>
+    </p>
+
+    <p>
+        <?php echo _('Sujet') ?> : 
+        <input type="text" id="email_subject" name="email_subject" 
class="input_text">
+        <span class="notice" id="email_subject_span"></span>
+    </p>
+    <p>
+        <?php echo _('Message') ?> : 
+        <textarea style="vertical-align: top;width:80rem;height:20rem;" 
name="email_message" class="input_text">               </textarea>
+    </p>
+    <p>
+        <input type="checkbox" name="email_copy"> <?php echo _("Envoyer copie 
à l'expéditeur"); ?>
+
+    </p>
+    <h2 class="note"><?php echo _('Inclure dans le suivi') ?> </h2>
+    <p>
+        <input type="checkbox" name="save_followup"> <?php echo _("Sauver dans 
le suivi"); ?>
+    </p>
+    <table>
+        <tr>
+            <td>
+                <label><?php echo _('Date'); ?> :</label>
+            </td>        
+            <td>
+                <?php echo $date->input(); ?>
+            </td>
+        </tr>
+        <tr>
+            <td>
+                <label><?php echo _('Date rappel'); ?> :</label>
+            </td>
+            <td>
+                <?php echo $remind_date->input(); ?>
+            </td>
+        </tr>
+        <tr>
+            <td>
+                <label>
+                    <?php echo _('Profil'); ?> :
+                </label>
+            </td>
+            <td>
+
+                <?php echo $ag_dest->input(); ?>
+            </td>
+        </tr>
+        <tr>
+            <td>
+                <label><?php echo _('Titre'); ?> : </label>
+            </td>
+            <td>
+                <?php echo $titre->input(); ?>
+            </td>
+        </tr>
+        <tr>
+            <td>
+                <label>
+                    <?php echo _('Catégorie'); ?> :
+                </label>
+            </td>
+            <td>
+                <?php echo $category->input(); ?>
+            </td>
+        </tr>
+    </table>
+
+    <p>
+        <?php
+        echo HtmlInput::submit('choice_sel', _('Exécuter'));
+        ?>
+    </p>
+</form>
+<script>
+    function verify_invoicing()
+    {
+        if ($('invoice_radio').checked) {
+            if ($('email_from').value.trim() == "") {
+                $('email_from').style.border = "solid 2px red";
+                $('email_from_span').innerHTML = " Obligatoire";
+                return false;
+            } else {
+                $('email_from_span').hide();
+                $('email_from').style.border = "";
+            }
+            if ($('email_subject').value.trim() == "") {
+                $('email_subject').style.border = "solid 2px red";
+                $('email_subject_span').innerHTML = " Obligatoire";
+                return false;
+            } else {
+                $('email_subject_pan').hide();
+                $('email_subject').style.border = "";
+            }
+        }
+    }
+</script>
+<
\ No newline at end of file

Added: trunk/invoicing/include/invoice_send_mail_route.inc.php
===================================================================
--- trunk/invoicing/include/invoice_send_mail_route.inc.php                     
        (rev 0)
+++ trunk/invoicing/include/invoice_send_mail_route.inc.php     2014-03-14 
16:56:29 UTC (rev 720)
@@ -0,0 +1,32 @@
+<?php
+
+/*
+ *   This file is part of NOALYSS.
+ *
+ *   NOALYSS 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.
+ *
+ *   NOALYSS 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 NOALYSS; if not, write to the Free Software
+ *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+*/
+
+// Copyright Author Dany De Bontridder address@hidden
+$step=HtmlInput::default_value_request("sa",null);
+
+switch ( $step) 
+{
+    case null:
+        require 'invoice_send_mail_input.inc.php';
+        break;
+    case 'send':
+        require 'invoice_send_mail.inc.php';
+        break;
+}
\ No newline at end of file

Modified: trunk/invoicing/include/invoicing.inc.php
===================================================================
--- trunk/invoicing/include/invoicing.inc.php   2014-03-12 16:47:17 UTC (rev 
719)
+++ trunk/invoicing/include/invoicing.inc.php   2014-03-14 16:56:29 UTC (rev 
720)
@@ -21,10 +21,10 @@
 $ledger = new Acc_Ledger_Sold_Generate($cn, -1);
 $_GET['ledger_type'] = 'VEN';
 //var_dump($_GET);
-$request = HtmlInput::default_value_get('action', -2);
+$request = HtmlInput::default_value_request('action', -2);
 if ($request <> -2)
 {
-    if (!isset($_GET['sel_sale']))
+    if (!isset($_REQUEST['sel_sale']))
     {
         echo h2("Rien n'a été choisi", 'class="notice"');
     } else
@@ -41,7 +41,7 @@
                 break;
             case 3:
                 // Envoi facture par email
-                require('invoice_send_mail.inc.php');
+                require('invoice_send_mail_route.inc.php');
                 break;
         }
         exit();
@@ -84,49 +84,22 @@
     <ul style="list-style-type: none">
         <li>
             
-            <input type="radio" name="action" value="1" 
-                   
onclick="$('invoice_div').hide();$('send_mail_div').hide();">
+            <input type="radio" name="action" value="1" >
             <?php echo _('Télécharger toutes les factures') ?>
         </li>
         <li>
           
             <input type="radio" name="action" value="2" 
-                   
onclick="$('invoice_div').show();$('send_mail_div').hide();">
+                   onclick="$('invoice_div').show();">
               <?php echo _('Générer les factures') ?>
             <div id="invoice_div" style="display:none">
                 <?php echo _('Document à générer'); ?> : <?php echo 
$document->input(); ?>
             </div>
         </li>
         <li>
-            
-            <input type="radio" name="action" id="invoice_radio" value="3" 
-                   
onclick="$('invoice_div').hide();$('send_mail_div').show();">
+            <input type="radio" name="action" id="invoice_radio" value="3">
             <?php echo _('Envoi des factures par email') ?>
-            <div id="send_mail_div" style="display:none">
-                <h2 class="note"><?php echo _('Envoi uniquement à ceux ayant 
une adresse email et une facture')?> </h2>
-                <p>
-                    <input type="checkbox" name="pdf"> <?php echo 
_('Conversion en PDF'); ?>
-                </p>
-                <p>
-                    <?php echo _('Email envoyé par'); ?> :
-                     <input type="text" id="email_from" name="email_from" 
class="input_text">
-                     <span class="notice" id="email_from_span"></span>
-                </p>
-                
-                <p>
-                    <?php echo _('Sujet')?> : 
-                    <input type="text" id="email_subject" name="email_subject" 
class="input_text">
-                    <span class="notice" id="email_subject_span"></span>
-                </p>
-                <p>
-                    <?php echo _('Message')?> : 
-                    <textarea style="vertical-align: top;width:23%;height:10%" 
name="email_message" class="input_text">               </textarea>
-                </p>
-                <p>
-                    <input type="checkbox" name="email_copy"> <?php echo 
_("Envoyer copie à l'expéditeur"); ?>
-                   
-                </p>
-            </div>
+           
         </li>
     </ul>   
     <p>
@@ -135,28 +108,6 @@
         ?>
     </p>
 </form>
-<script>
-    function verify_invoicing()
-    {
-        if ($('invoice_radio').checked) {
-            if ($('email_from').value.trim()=="") {
-                $('email_from').style.border="solid 2px red";
-                $('email_from_span').innerHTML=" Obligatoire";
-                return false;
-            } else {
-                $('email_from_span').hide();
-                $('email_from').style.border="";
-            }
-            if ($('email_subject').value.trim()=="") {
-                $('email_subject').style.border="solid 2px red";
-                $('email_subject_span').innerHTML=" Obligatoire";
-                return false;
-            }else {
-                $('email_subject_pan').hide();
-                $('email_subject').style.border="";
-            }
-        }
-    }
-</script>
+
     
     
\ No newline at end of file



---
PhpCompta est un logiciel de comptabilité libre en ligne (full web)
Projet opensource http://www.phpcompta.eu



reply via email to

[Prev in Thread] Current Thread [Next in Thread]