]> _ Git - dtlc.git/commitdiff
wip #7378 @3
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 26 Mar 2025 18:15:23 +0000 (19:15 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 26 Mar 2025 18:15:23 +0000 (19:15 +0100)
framework/application/Bootstrap.php
framework/application/DTLC/Util.php
framework/application/configs/application.ini
framework/application/controllers/AdminajaxController.php
framework/application/controllers/AdminajaxpopupController.php
framework/application/controllers/MaintenanceController.php
framework/application/forms/Devis.php
framework/application/views/scripts/devis/index.phtml
framework/library/CubeIT/Mail/Transport/Postal.php [new file with mode: 0644]

index af80149c60a9f8e6f6efd497101560f7100c588f..10b8833d9ce78a0aa2bccce76b6ad8a43003ed17 100644 (file)
 <?php
 
-class Bootstrap extends CubeIT_Bootstrap {
-
-       protected function _initMinimum() {
-               parent::_initMinimum();
-               // If a project with html display (don't activate by default for web services apps)
-               $this->bootstrap('doctype');
-       }
-
-       protected function _initScripts() {
-               parent::_initScripts();
-       }
-
-       protected function _initRouter($initCms = true, $standard = true) {
-               $router = parent::_initRouter($initCms, $standard);
-               $router->addStandardRoute('devis', 'devis');
-               $router->addStandardRoute('payment', 'payment');
-               $router->addStandardRoute('sogecommerce', 'sogecommerce');
-               return $router;
-       }
-
-       /**
-        *
-        * @param \Doctrine\DBAL\Schema\Schema $schema
-        * @param mixed $options
-        */
-       protected function _defineSchema(&$schema, $options) {
-               parent::_defineSchema($schema, $options);
-
-               $devis = $schema->createTable('devis');
-               $devis->addColumn('id', 'integer', array('unsigned' => true, 'autoincrement' => true));
-               $devis->setPrimaryKey(array('id'));
-               $devis->addColumn('nom', 'string', array('length' => 128));
-               $devis->addIndex(array('nom'));
-               $devis->addColumn('email', 'string', array('length' => 128));
-               $devis->addIndex(array('email'));
-               $devis->addColumn('prenom', 'string', array('length' => 128));
-               $devis->addIndex(array('prenom'));
-               $devis->addColumn('societe', 'string', array('length' => 128));
-               $devis->addIndex(array('societe'));
-               $devis->addColumn('telephone', 'string', array('length' => 32));
-               $devis->addColumn('mobile', 'string', array('length' => 32));
-               $devis->addColumn('adresse', 'string', array('length' => 128));
-               $devis->addColumn('code_postal', 'string', array('length' => 8));
-               $devis->addColumn('ville', 'string', array('length' => 128));
-               $devis->addColumn('country', 'string', array('length' => 4, 'default' => 'FR'));
-               $devis->addColumn('tva_intra', 'string', array('length' => 32));
-               $devis->addColumn('reference', 'text');
-               $devis->addColumn('demandes', 'text');
-               $devis->addColumn('magasin', 'string', array('length' => 32));
-               $devis->addIndex(array('magasin'));
-               $devis->addColumn('livraison', 'boolean');
-               $devis->addColumn('adresse_livraison', 'string', array('length' => 512));
-               $devis->addColumn('complement_livraison', 'string', array('length' => 512));
-               $devis->addColumn('fichiers', 'text');
-               $devis->addColumn('date', 'datetime');
-               $devis->addColumn('tva', 'float', array('default' => '20'));
-               $devis->addIndex(array('date'));
-               $devis->addColumn('status', 'integer');
-               $devis->addIndex(array('status'));
-               $devis->addColumn('secret', 'string', array('length' => 40));
-               $devis->addIndex(array('secret'));
-               $devis->addColumn('details', 'text');
-               // Réponse
-               $devis->addColumn('reponse', 'text');
-               $devis->addColumn('date_reponse', 'datetime');
-               $devis->addColumn('montant_ht', 'float');
-               $devis->addColumn('montant_ttc', 'float');
-               // Paiement
-               $devis->addColumn('infos_paiement', 'text');
-               $devis->addColumn('date_paiement', 'datetime');
-       }
-
-
-       protected function _initDbViews() {
-               parent::_initDbViews();
-               $db = Zend_Db_Table::getDefaultAdapter();
-               $db->createView("devis_view", $db->select()->from('devis', array('*', 'date_action' => 'GREATEST(`date`,`date_reponse`,`date_paiement`)')));
-       }
-
-
-       /**
-        *
-        * @return array
-        */
-       public function getCMSTemplates() {
-               $templates = parent::getCMSTemplates();
-               $templates['Pages'] = array(
-                       'services' => 'Services',
-                       'servicesdetail' => 'Service (détail)',
-                       'magasins' => 'Magasins',
-                       'devis' => 'Devis',
-                       'faq' => 'FAQ'
-               );
-               return $templates;
-       }
-
-       /**
-        *
-        * @return array
-        */
-       protected function _getNavigationFields() {
-               return array('shortTitle', 'longTitle', 'url', 'target', 'theme', 'infos');
-       }
-
-       protected function _makeNavigationOnePage(&$navigation, $r, $t, $isAdmin, $locale = false) {
-               $page = parent::_makeNavigationOnePage($navigation, $r, $t, $isAdmin, $locale);
-               if (isset($t['theme'])) {
-                       $page->setCustomHtmlAttrib('data-theme', $t['theme']);
-               }
-               if (isset($t['infos'])) {
-                       $page->infos = $t['infos'];
-               }
-
-               return $page;
-       }
-
-       protected function __initDefaultMailTransport() {
-               return new CubeIT_Mail_Transport_Mandrill();
-               //return new CubeIT_Mail_Transport_Sendmail('-freturn@detouteslescouleurs.com');
-       }
-
-       protected function _initAcl() {
-               $acl = parent::_initAcl();
-
-               $acl->addRole('devis', 'staff');
-               $acl->addResource('administration/devis');
-               $acl->addResource('administration/users/devis', 'administration/users/admin');
-               $acl->allow('devis', 'administration/devis');
-
-               return $acl;
-       }
-
-
-       function __destroy() {
-               endProfile();
-       }
+class Bootstrap extends CubeIT_Bootstrap
+{
+
+    protected function _initMinimum()
+    {
+        parent::_initMinimum();
+        // If a project with html display (don't activate by default for web services apps)
+        $this->bootstrap('doctype');
+    }
+
+    protected function _initScripts()
+    {
+        parent::_initScripts();
+    }
+
+    protected function _initRouter($initCms = true, $standard = true)
+    {
+        $router = parent::_initRouter($initCms, $standard);
+        $router->addStandardRoute('devis', 'devis');
+        $router->addStandardRoute('payment', 'payment');
+        $router->addStandardRoute('sogecommerce', 'sogecommerce');
+        return $router;
+    }
+
+    /**
+     *
+     * @param \Doctrine\DBAL\Schema\Schema $schema
+     * @param mixed $options
+     */
+    protected function _defineSchema(&$schema, $options)
+    {
+        parent::_defineSchema($schema, $options);
+
+        $devis = $schema->createTable('devis');
+        $devis->addColumn('id', 'integer', array('unsigned' => true, 'autoincrement' => true));
+        $devis->setPrimaryKey(array('id'));
+        $devis->addColumn('nom', 'string', array('length' => 128));
+        $devis->addIndex(array('nom'));
+        $devis->addColumn('email', 'string', array('length' => 128));
+        $devis->addIndex(array('email'));
+        $devis->addColumn('prenom', 'string', array('length' => 128));
+        $devis->addIndex(array('prenom'));
+        $devis->addColumn('societe', 'string', array('length' => 128));
+        $devis->addIndex(array('societe'));
+        $devis->addColumn('telephone', 'string', array('length' => 32));
+        $devis->addColumn('type', 'string', array('length' => 3));
+        $devis->addColumn('mobile', 'string', array('length' => 32));
+        $devis->addColumn('adresse', 'string', array('length' => 128));
+        $devis->addColumn('code_postal', 'string', array('length' => 8));
+        $devis->addColumn('ville', 'string', array('length' => 128));
+        $devis->addColumn('country', 'string', array('length' => 4, 'default' => 'FR'));
+        $devis->addColumn('tva_intra', 'string', array('length' => 32));
+        $devis->addColumn('reference', 'text');
+        $devis->addColumn('demandes', 'text');
+        $devis->addColumn('magasin', 'string', array('length' => 32));
+        $devis->addIndex(array('magasin'));
+        $devis->addColumn('livraison', 'boolean');
+        $devis->addColumn('adresse_livraison', 'string', array('length' => 512));
+        $devis->addColumn('complement_livraison', 'string', array('length' => 512));
+        $devis->addColumn('fichiers', 'text');
+        $devis->addColumn('date', 'datetime');
+        $devis->addColumn('tva', 'float', array('default' => '20'));
+        $devis->addIndex(array('date'));
+        $devis->addColumn('status', 'integer');
+        $devis->addIndex(array('status'));
+        $devis->addColumn('secret', 'string', array('length' => 40));
+        $devis->addIndex(array('secret'));
+        $devis->addColumn('details', 'text');
+        // Réponse
+        $devis->addColumn('reponse', 'text');
+        $devis->addColumn('date_reponse', 'datetime');
+        $devis->addColumn('montant_ht', 'float');
+        $devis->addColumn('montant_ttc', 'float');
+        // Paiement
+        $devis->addColumn('infos_paiement', 'text');
+        $devis->addColumn('date_paiement', 'datetime');
+        $devis->addColumn('methode_paiement', 'string', array('length' => 40));
+    }
+
+
+    protected function _initDbViews()
+    {
+        parent::_initDbViews();
+        $db = Zend_Db_Table::getDefaultAdapter();
+        $db->createView("devis_view", $db->select()->from('devis', array('*', 'date_action' => 'GREATEST(`date`,`date_reponse`,`date_paiement`)')));
+    }
+
+
+    /**
+     *
+     * @return array
+     */
+    public function getCMSTemplates()
+    {
+        $templates = parent::getCMSTemplates();
+        $templates['Pages'] = array(
+            'services' => 'Services',
+            'servicesdetail' => 'Service (détail)',
+            'magasins' => 'Magasins',
+            'devis' => 'Devis',
+            'faq' => 'FAQ'
+        );
+        return $templates;
+    }
+
+    /**
+     *
+     * @return array
+     */
+    protected function _getNavigationFields()
+    {
+        return array('shortTitle', 'longTitle', 'url', 'target', 'theme', 'infos');
+    }
+
+    protected function _makeNavigationOnePage(&$navigation, $r, $t, $isAdmin, $locale = false)
+    {
+        $page = parent::_makeNavigationOnePage($navigation, $r, $t, $isAdmin, $locale);
+        if (isset($t['theme'])) {
+            $page->setCustomHtmlAttrib('data-theme', $t['theme']);
+        }
+        if (isset($t['infos'])) {
+            $page->infos = $t['infos'];
+        }
+
+        return $page;
+    }
+
+    protected function __initDefaultMailTransport()
+    {
+        $transport = $this->getOpt("mail.transport", 'mandrill');
+        if ($transport === 'mandrill') {
+            return new CubeIT_Mail_Transport_Mandrill();
+        } else if ($transport === 'postal') {
+            return new CubeIT_Mail_Transport_Postal();
+        }
+
+        //return new CubeIT_Mail_Transport_Sendmail('-freturn@detouteslescouleurs.com');
+    }
+
+    protected function _initAcl()
+    {
+        $acl = parent::_initAcl();
+
+        $acl->addRole('devis', 'staff');
+        $acl->addResource('administration/devis');
+        $acl->addResource('administration/users/devis', 'administration/users/admin');
+        $acl->allow('devis', 'administration/devis');
+
+        return $acl;
+    }
+
+
+    function __destroy()
+    {
+        endProfile();
+    }
 
 }
index 11d198e488585cb1f26faf94e07e1dea85c002c1..7a7434e02b3c0e0cdf65956d9c0c34358658fba4 100644 (file)
@@ -39,7 +39,7 @@ class DTLC_Util
             $m = 11;
         }
         $date = new CubeIT_Date($devis->date_paiement, CubeIT_Date::MYSQL);
-        return $m . '-' . $date->toString(CubeIT_Date::YEAR_SHORT) . 'NET' . $devis->id;
+        return $m . '-' . $date->toString(CubeIT_Date::YEAR_SHORT) . ($devis->type ?: 'NET') . $devis->id;
     }
 
     public static function getQuoteNumber($devis)
@@ -50,7 +50,7 @@ class DTLC_Util
             $m = 11;
         }
         $date = new CubeIT_Date($devis->date_reponse, CubeIT_Date::MYSQL);
-        return $m . '-' . $date->toString(CubeIT_Date::YEAR_SHORT) . 'NET' . $devis->id;
+        return $m . '-' . $date->toString(CubeIT_Date::YEAR_SHORT) . ($devis->type ?: 'NET') . $devis->id;
     }
 
 
index 92819a6dae261b28ce1b8ca0ad4c810e31d028d4..fa80ac0d95f1113e31b89f6e522a12b97eee6c81 100644 (file)
@@ -49,9 +49,7 @@ mail.test = APPLICATION_PATH "/../data/email/test"
 mail.bcc = test@cubedesigners.com
 mail.subjectPrefix = ""
 
-mailjet.username = 784e4d0b73f52fe9cb7933e81ceef122
-mailjet.password = 1746fae4434c86c702548bf60fa8901a
-
+mail.transport = mandrill
 mandrill.username = "De toutes les couleurs"
 mandrill.password = QigtHBMVpBYo3n29DAZWrQ
 
@@ -89,6 +87,12 @@ sogenactif.merchant = 002001000000001
 sogecommerce.mode = TEST
 sogecommerce.key = M36rdUrUHlN15u4x
 
+mail.transport = postal
+postal.username = dtlc/dtlc-dev
+postal.password = BeHsGbUhvMAbNsT3xpkELVUV
+postal.server = postal.cubedesigners.com
+
+
 webhost = dev.detouteslescouleurs.com
 
 mail.subjectPrefix = "/!\ Site de développement | "
\ No newline at end of file
index bdd70b8df012802d8a0bfcef96bad068115045ff..5f4b7e7277114ac2f345d9dc0a0429671ca3d514 100644 (file)
@@ -200,4 +200,19 @@ L\'équipe "De toutes les couleurs"');
         $this->_datas->addReloadPopup();
     }
 
+    public function devisConvertToStoreOrder($id)
+    {
+        $db = $this->getDb();
+        $bind['type'] = 'MAG';
+        $bind['date_reponse'] = $bind['date_paiement'] = $_POST['date'];
+        $bind['methode_paiement'] = $_POST['methode_paiement'];
+        $bind['status'] = DTLC_Form_Devis::PAYE;
+        $db->compliantUpdate('devis', $bind, $db->quoteInto('id = ?', $id));
+
+        $r = Bootstrap::getInstance()->getDb()->select()->from('devis')->where('id = ?', $id)->query()->fetch();
+
+        $this->_datas->addClosePopup();
+        $this->_datas->addRedirection('/devis/index/' . $id . '/' . $r->secret);
+    }
+
 }
index 95acceb6105c4e823239b9860a380a1834cae0db..491f2d7c148a3178bb544df75bc6d6e696e932e6 100644 (file)
@@ -51,6 +51,49 @@ class AdminajaxpopupController extends CubeIT_Controller_Admin_AdminajaxpopupCon
         return $res;
     }
 
+    public function devisConvertToStoreOrder($id)
+    {
+        if (!$this->isAllowed('administration/devis')) {
+            throw new Exception('Forbidden action');
+        }
+        $w = 430;
+        $this->setPopupWidth($w)
+            ->setPopupMaxWidth($w)
+            ->setPopupBackWidth($w);
+
+        $this->view->title = "Convertir en commande magasin";
+
+        $r = Bootstrap::getInstance()->getDb()->select()->from('devis')->where('id = ?', $id)->query()->fetch();
+        $res = '<div class="zend_form">';
+        $res .= '<form method="post" class="ajax" action="/admin/ajax/devisConvertToStoreOrder/' . $id . '">';
+        $res .= '<div class="elementwrap">';
+        $res .= '<dt>';
+        $res .= 'Moyen de paiement';
+        $res .= '</dt>';
+        $res .= '<dd>';
+        $res .= '<select name="methode_paiement">
+<option name="CB">Carte bancaire</option>
+<option name="ESPECES">Espèces</option>
+<option name="CHEQUE">Chèque</option>
+<option name="VIREMENT">Virement</option>
+<option name="SOGENACTIF">Sogenactif</option>
+</select>';
+        $res .= '</dd>';
+        $res .= '</div>';
+        $res .= '<div class="elementwrap">';
+        $res .= '<dt>';
+        $res .= 'Date';
+        $res .= '</dt>';
+        $res .= '<dd>';
+        $res .= '<input name="date" type="date" value="' . substr(max($r->date_reponse,$r->date), 0, 10) . '" />';
+        $res .= '</dd>';
+        $res .= '</div>';
+        $res .= '<a href="#" class="submit button">Convertir</a>';
+        $res .= '</form>';
+        $res .= '</div>';
+        return $res;
+    }
+
     public function devisDone($id)
     {
         if (!$this->isAllowed('administration/devis')) {
@@ -102,7 +145,7 @@ Votre commande n°' . $id . ' a été enlevée par TNT ce jour, livraison prévu
 Cordialement,
 La direction'];
         $r = Bootstrap::getInstance()->getDb()->select()->from('devis')->where('id = ?', $id)->query()->fetch();
-        $m=DTLC_Util::getMagasinById($r->magasin);
+        $m = DTLC_Util::getMagasinById($r->magasin);
         $res = '<div class="zend_form">';
         $res .= '<form method="post" class="ajax" action="/admin/ajax/devisDone/' . $id . '">';
         $res .= '<div class="elementwrap">';
@@ -110,8 +153,8 @@ La direction'];
         $res .= '<dd><select name="fill">';
         $i = 0;
         foreach ($messages as $subject => $message) {
-            if($message!=='') {
-                $message .= "\n".$m['telephone'];
+            if ($message !== '') {
+                $message .= "\n" . $m['telephone'];
             }
             $res .= '<option data-message="' . htmlentities($message) . '" value="' . $i . '">' . $subject . '</option>';
             $i++;
index d2b831ba10949407eef14ada69121e67ed3c274b..7fa7c533165400044d345fd2c619cefdd4074e7c 100644 (file)
@@ -3,98 +3,98 @@
 class MaintenanceController extends CubeIT_Controller_MaintenanceController
 {
 
-       /*public function importDb() {
-
-               set_time_limit(0);
-
-               $former = $this->getFormerDb();
-               $db = $this->getDb();
-
-               CubeIT_Firephp::disable();
-
-               $db->exec('TRUNCATE TABLE devis');
-               $q = $former->select()->from('devis')->query();
-               while ($r = $q->fetch()) {
-
-                       $magasin = $r->boutique == 1 ? 'paris11' : 'paris15';
-
-                       $demandes = array(
-                               array(
-                                       'type' => 'former',
-                                       'pages' => $r->pages,
-                                       'exemplaires' => $r->exemplaires,
-                                       'format' => $r->format,
-                                       'recto' => $r->recto,
-                                       'grammage' => $r->grammage,
-                                       'couleur' => $r->couleur,
-                                       'noirblanc' => $r->noirblanc
-                               )
-                       );
-
-                       $bind = array(
-                               'id' => $r->id,
-                               'prenom' => $r->prenom,
-                               'nom' => $r->nom,
-                               'societe' => $r->societe,
-                               'telephone' => $r->telephone,
-                               'mobile' => $r->mobile,
-                               'email' => $r->email,
-                               'adresse' => $r->adresse,
-                               'code_postal' => $r->code_postal,
-                               'ville' => $r->ville,
-                               'magasin' => $magasin,
-                               'livraison' => $r->livraison,
-                               'status' => $r->status,
-                               'demandes' => json_encode($demandes),
-                               'details' => json_encode(array('descriptif_0' => $r->demande, 'prix_0' => $r->ttc)),
-                               'date' => $this->timestamp2datetime($r->date_demande),
-                               // Réponse
-                               'reponse' => $r->reponse,
-                               'date_reponse' => $this->timestamp2datetime($r->date_devis),
-                               'montant_ht' => $r->ht,
-                               'montant_ttc' => $r->ttc,
-                               'secret' => $r->secret,
-                               // Paiement
-                               'infos_paiement' => $r->infos_paiement,
-                               'date_paiement' => $this->timestamp2datetime($r->date_paiement));
-
-
-                       $db->insert('devis', $bind);
-               }
-
-
-               CubeIT_Firephp::enable();
-               exit;
-       }*/
-
-       protected function timestamp2datetime($time)
-       {
-               if ($time == 0) {
-                       return 0;
-               }
-               $date = new Zend_Date($time, Zend_Date::TIMESTAMP);
-               return $date->toString(Zend_Date::ISO_8601);
-       }
-
-       public function date()
-       {
-               echo CubeIT_Date::now();
-       }
-
-       public function dotclear()
-       {
-               $txt = '¤¤purple¤blabla¤¤';
-               echo $txt;
-               echo CubeIT_Markup_Dotclear::convert($txt);
-       }
-
-       public function testMail()
-       {
-               $mail = new CubeIT_Mail();
-               $mail->setFrom('contact@detouteslescouleurs.com');
-               $mail->addTo('test@cubedesigners.com');
-               $mail->setSubject('Test mandrill');
-               $mail->setBodyText('Test mandrill https://www.detouteslescouleurs.com');
-               $mail->send(new CubeIT_Mail_Transport_Mandrill());
-       }
+    /*public function importDb() {
+
+        set_time_limit(0);
+
+        $former = $this->getFormerDb();
+        $db = $this->getDb();
+
+        CubeIT_Firephp::disable();
+
+        $db->exec('TRUNCATE TABLE devis');
+        $q = $former->select()->from('devis')->query();
+        while ($r = $q->fetch()) {
+
+            $magasin = $r->boutique == 1 ? 'paris11' : 'paris15';
+
+            $demandes = array(
+                array(
+                    'type' => 'former',
+                    'pages' => $r->pages,
+                    'exemplaires' => $r->exemplaires,
+                    'format' => $r->format,
+                    'recto' => $r->recto,
+                    'grammage' => $r->grammage,
+                    'couleur' => $r->couleur,
+                    'noirblanc' => $r->noirblanc
+                )
+            );
+
+            $bind = array(
+                'id' => $r->id,
+                'prenom' => $r->prenom,
+                'nom' => $r->nom,
+                'societe' => $r->societe,
+                'telephone' => $r->telephone,
+                'mobile' => $r->mobile,
+                'email' => $r->email,
+                'adresse' => $r->adresse,
+                'code_postal' => $r->code_postal,
+                'ville' => $r->ville,
+                'magasin' => $magasin,
+                'livraison' => $r->livraison,
+                'status' => $r->status,
+                'demandes' => json_encode($demandes),
+                'details' => json_encode(array('descriptif_0' => $r->demande, 'prix_0' => $r->ttc)),
+                'date' => $this->timestamp2datetime($r->date_demande),
+                // Réponse
+                'reponse' => $r->reponse,
+                'date_reponse' => $this->timestamp2datetime($r->date_devis),
+                'montant_ht' => $r->ht,
+                'montant_ttc' => $r->ttc,
+                'secret' => $r->secret,
+                // Paiement
+                'infos_paiement' => $r->infos_paiement,
+                'date_paiement' => $this->timestamp2datetime($r->date_paiement));
+
+
+            $db->insert('devis', $bind);
+        }
+
+
+        CubeIT_Firephp::enable();
+        exit;
+    }*/
+
+    protected function timestamp2datetime($time)
+    {
+        if ($time == 0) {
+            return 0;
+        }
+        $date = new Zend_Date($time, Zend_Date::TIMESTAMP);
+        return $date->toString(Zend_Date::ISO_8601);
+    }
+
+    public function date()
+    {
+        echo CubeIT_Date::now();
+    }
+
+    public function dotclear()
+    {
+        $txt = '¤¤purple¤blabla¤¤';
+        echo $txt;
+        echo CubeIT_Markup_Dotclear::convert($txt);
+    }
+
+    public function testMail()
+    {
+        $mail = new CubeIT_Mail();
+        $mail->setFrom('contact@detouteslescouleurs.com');
+        $mail->addTo('test@cubedesigners.com');
+        $mail->setSubject('Test Mail transport DTLC');
+        $mail->setBodyText('Test https://www.detouteslescouleurs.com');
+        $mail->send();
+    }
 }
index c6b380cff2b656fcc95529f15b0dbf0544b8698a..1d5c215a11fe2ab7fdb9a76316df2f8a01a0519c 100644 (file)
 <?php
 
-class DTLC_Form_Devis extends CubeIT_Form_List {
-
-       const REDACTION = -1;
-       const ATTENTE_REPONSE = 0;
-       const ATTENTE_PAIEMENT = 1;
-       const PAYE = 2;
-       const ANNULE = 4;
-       const DONE = 5;
-
-       protected $_status = DTLC_Form_Devis::REDACTION;
-       protected $_admin = false;
-       protected $_envoiText;
-       protected $_confirmationText;
-
-       public function init() {
-               parent::init();
-
-               $this->setAction('/ajax/devis');
-               $this->setSubmitMessage("Veuillez patienter");
-               $this->addClass('edit');
-               $this->setAjax(true);
-               $this->addClass('devis');
-               $this->setId('devis');
-               $this->setFilterColumns(array('status', 'magasin'));
-
-               $bootstrap = Bootstrap::getInstance();
-
-               $tva = new Zend_Form_Element_Hidden('tva');
-               $tva->setValue($bootstrap->getOpt('tva'));
-               $this->addElement($tva);
-       }
-
-       public function renderList(Zend_View_Abstract $view, $element = '', $prefix = 'admin', $div = false, $dataFilters = null, $search = true) {
-               $this->_initList();
-               if ($this->getElement('id') == null) {
-                       $this->addElement(new CubeIT_Form_Element_Id());
-               }
-               return parent::renderList($view, $element, $prefix, $div, $dataFilters, $search);
-       }
-
-       public function getEnvoiText() {
-               return $this->_envoiText;
-       }
-
-       public function setEnvoiText($envoiText) {
-               $this->_envoiText = $envoiText;
-               return $this;
-       }
-
-       public function getConfirmationText() {
-               return $this->_confirmationText;
-       }
-
-       public function setConfirmationText($confirmationText) {
-               $this->_confirmationText = $confirmationText;
-               return $this;
-       }
-
-       public function getAdmin() {
-               return $this->_admin;
-       }
-
-
-       public function setAdmin($admin = true) {
-               $this->_admin = $admin;
-               if ($admin) {
-                       $this->addClass('admin');
-               } else {
-                       $this->removeClass('admin');
-               }
-               return $this;
-       }
-
-       public function getStatus() {
-               return $this->_status;
-       }
-
-       public function setStatus($status) {
-               $this->_status = $status;
-               $this->_initFields();
-               return $this;
-       }
-
-       protected function _initFields() {
-               $this->_setAdminInfos();
-               $this->_setMagasins();
-               $this->_setCoordonnees();
-               $this->_setDemandes();
-               $this->_setFichiers();
-               $this->_setLivraison();
-               $this->_setAdminReponse();
-               $this->_setEnvoyer();
-
-               $this->_initList();
-       }
-
-       protected function _initList() {
-               $this->setNewTitle(null);
-               $this->setEditTitle('Editer le devis $id');
-               $this->setListTitle('Gestion des devis');
-               $this->setBaseTable('devis_view');
-               $this->setWriteTable('devis');
-               $this->setIdColumn('id');
-               $this->setTitleColumn('societe');
-               $this->setPerPage(30);
-               $this->setAdditionnalColumns(array('email', 'Prix TTC' => '_montant_ttc', 'status', 'Date' => 'date_action', 'magasin'));
-               $this->setEditLinkTemplate(array('helper' => 'link', 'url' => '/admin/devis/%s'));
-               $this->setAdditionnalActions(array(
-                               array($this, '_actionDone'),
-                               array($this, '_actionDownload'),
-                               array($this, '_actionDuplicate'),
-                               array($this, '_actionDocument')
-                       )
-               );
-               $this->setAdmin();
-
-               if ($this->getElement('nom') == null) {
-                       $this->_initFields();
-               }
-       }
-
-       public function getValueForDisplay($name, $r = null, $view = null) {
-               if ($name == '_montant_ttc') {
-                       if ($this->getValue('status') == 0) {
-                               return '-';
-                       }
-                       return number_format($this->details->getValue('montant_ttc'), 2, ',', '&nbsp;');
-               } else if ($name == 'date_action') {
-                       $date = new CubeIT_Date($r[$name], CubeIT_Date::MYSQL);
-                       return $date->toString('dd-MM-y HH:mm');
-               }
-
-               return parent::getValueForDisplay($name);
-       }
-
-       protected function _actionDuplicate($r, $view) {
-               if ($r['status'] < 1) {
-                       return;
-               }
-               return $view->linkAjax($view->imageSilk('page_copy'), '/admin/ajax/devisDuplicate/' . $r['id'], array('title' => 'Dupliquer ce devis', 'target' => '_blank'));
-       }
-
-       protected function _actionDone($r, $view) {
-               if ($r['status'] != 2) {
-                       return;
-               }
-               return $view->linkPopup($view->imageSilk('tick'), '/admin/ajaxpopup/devisDone/' . $r['id'], array('title' => 'Marquer comme terminé'));
-       }
-
-
-       protected function _actionDownload($r, $view) {
-               if (!$r['fichiers']) {
-                       return;
-               }
-               return $view->link($view->imageSilk('attach'), '/admin/devisDownload/' . $r['id'], array('title' => 'Télécharger les pièces jointes'));
-       }
-
-       protected function _actionDocument($r, $view) {
-               if ($r['status'] < 1) {
-                       return;
-               }
-               $title = 'Voir le devis';
-               $img = 'page_red';
-               if ($r['status'] == 2 || $r['status'] == 5) {
-                       $title = 'Voir la facture';
-                       $img = 'page_green';
-               }
-               return $view->link($view->imageSilk($img), '/devis/index/' . $r['id'] . '/' . $r['secret'], array('title' => $title, 'target' => '_blank'));
-       }
-
-       public function setDefaults(array $defaults) {
-               if ($this->getElement('nom') == null) {
-                       $this->_initFields();
-               }
-
-               return @parent::setDefaults($defaults);
-       }
-
-       public function isValid($data) {
-               if ($this->getElement('nom') == null) {
-                       $this->_initFields();
-               }
-               return parent::isValid($data);
-       }
-
-       public function render(Zend_View_Interface $view = null) {
-               if ($this->getElement('nom') == null) {
-                       $this->_initFields();
-               }
-
-               if ($this->getAdmin()) {
-                       $d = $this->getSubForm('details');
-
-                       if (null != $d) {
-                               if ($d->isEmpty()) {
-                                       $demandes = $this->getSubForm('demandes');
-                                       $demandes = $demandes->getTextes();
-                                       $details = array();
-
-                                       foreach ($demandes as $k => $d) {
-                                               $details['descriptif_' . $k] = $d;
-                                       }
-
-                                       $this->getSubForm('details')->setDefaults($details);
-                               }
-                               $this->removeSubForm('demandes');
-                       }
-               }
-
-               if (!$this->getValue('livraison')) {
-                       $this->removeElement('adresse_livraison');
-                       $this->removeElement('complement_livraison');
-               }
-
-               return parent::render($view);
-       }
-
-       public function deleteItem($id) {
-               $this->_initList();
-               parent::deleteItem($id);
-       }
-
-       protected function _setMagasins() {
-               $validator = new Zend_Validate_NotEmpty();
-               $validator->setMessage('Veuillez choisir un magasin');
-
-               $mags = DTLC_Util::getMagasins();
-               $options = array();
-               foreach ($mags as $m) {
-                       $options[$m['id']] = $m['nom'];
-               }
-
-               $magasins = new Zend_Form_Element_Radio('magasin');
-               $magasins->setRegisterInArrayValidator(false);
-               if ($this->getAdmin()) {
-                       $magasins->setLabel('Magasin');
-               }
-               $magasins->setRequired(true);
-               $magasins->setMultiOptions($options);
-               $magasins->clearValidators();
-               $magasins->addValidator($validator);
-               $this->addElement($magasins);
-
-               $legend = $this->getAdmin() ? 'Magasin' : 'Choix du magasin*';
-               $this->addDisplayGroup(array('magasin'), 'magasins_group', array('legend' => $legend));
-       }
-
-       protected function _setCoordonnees() {
-
-               $notEmptyValidator = new Zend_Validate_NotEmpty();
-               $notEmptyValidator->setMessage('Ce champ est obligatoire', Zend_Validate_NotEmpty::IS_EMPTY);
-               $notEmptyValidator->zfBreakChainOnFailure = true;
-
-               $emailValidator = new Zend_Validate_EmailAddress();
-               $emailValidator->setMessage('Cette adresse est invalide', Zend_Validate_EmailAddress::INVALID_FORMAT);
-               $emailValidator->setMessage('Cette adresse est invalide', Zend_Validate_EmailAddress::INVALID_HOSTNAME);
-               $emailValidator->zfBreakChainOnFailure = true;
-
-               $societe = new Zend_Form_Element_Text('societe');
-               $societe->setLabel('Société');
-               $this->addElement($societe);
-
-               $prenom = new Zend_Form_Element_Text('prenom');
-               $prenom->setLabel('Prenom');
-               $prenom->setRequired(true);
-               $prenom->addValidator($notEmptyValidator);
-               $this->addElement($prenom);
-
-               $nom = new Zend_Form_Element_Text('nom');
-               $nom->setLabel('Nom');
-               $nom->setRequired(true);
-               $nom->addValidator($notEmptyValidator);
-               $this->addElement($nom);
-
-               $telephone = new CubeIT_Form_Element_Phone('telephone');
-               $telephone->setLabel('Téléphone');
-               $telephone->setRequired(true);
-               $telephone->addValidator($notEmptyValidator);
-               $this->addElement($telephone);
-
-               $mobile = new CubeIT_Form_Element_Phone('mobile');
-               $mobile->setLabel('Mobile');
-               $this->addElement($mobile);
-
-               $email = new CubeIT_Form_Element_Email('email');
-               $email->setLabel(__('Email'));
-               $email->setRequired(true);
-               $email->clearValidators();
-               $email->addValidator($notEmptyValidator, true);
-               $email->addValidator($emailValidator, true);
-               $this->addElement($email);
-
-               $adresse = new Zend_Form_Element_Textarea('adresse');
-               $adresse->setLabel('Adresse de facturation');
-               $adresse->setAttrib('rows', 2);
-               $adresse->setRequired(true);
-               $adresse->clearValidators();
-               $adresse->addValidator($notEmptyValidator, true);
-               $this->addElement($adresse);
-
-               $codepostal = new Zend_Form_Element_Text('code_postal');
-               $codepostal->setLabel(__('Code postal'));
-               $codepostal->setRequired(true);
-               $codepostal->clearValidators();
-               $codepostal->addValidator($notEmptyValidator, true);
-               $this->addElement($codepostal);
-
-               $ville = new Zend_Form_Element_Text('ville');
-               $ville->setLabel(__('Ville'));
-               $ville->setRequired(true);
-               $ville->clearValidators();
-               $ville->addValidator($notEmptyValidator, true);
-               $this->addElement($ville);
-
-               $pays = new CubeIT_Form_Element_Country('pays');
-               $pays->setLabel(__('Pays'));
-               $pays->setRequired(true);
-               $pays->setDetectCountry(false);
+class DTLC_Form_Devis extends CubeIT_Form_List
+{
+
+    const REDACTION = -1;
+    const ATTENTE_REPONSE = 0;
+    const ATTENTE_PAIEMENT = 1;
+    const PAYE = 2;
+    const ANNULE = 4;
+    const DONE = 5;
+
+    protected $_status = DTLC_Form_Devis::REDACTION;
+    protected $_admin = false;
+    protected $_envoiText;
+    protected $_confirmationText;
+
+    public function init()
+    {
+        parent::init();
+
+        $this->setAction('/ajax/devis');
+        $this->setSubmitMessage("Veuillez patienter");
+        $this->addClass('edit');
+        $this->setAjax(true);
+        $this->addClass('devis');
+        $this->setId('devis');
+        $this->setFilterColumns(array('status', 'magasin'));
+
+        $bootstrap = Bootstrap::getInstance();
+
+        $tva = new Zend_Form_Element_Hidden('tva');
+        $tva->setValue($bootstrap->getOpt('tva'));
+        $this->addElement($tva);
+    }
+
+    public function renderList(Zend_View_Abstract $view, $element = '', $prefix = 'admin', $div = false, $dataFilters = null, $search = true)
+    {
+        $this->_initList();
+        if ($this->getElement('id') == null) {
+            $this->addElement(new CubeIT_Form_Element_Id());
+        }
+        return parent::renderList($view, $element, $prefix, $div, $dataFilters, $search);
+    }
+
+    public function getEnvoiText()
+    {
+        return $this->_envoiText;
+    }
+
+    public function setEnvoiText($envoiText)
+    {
+        $this->_envoiText = $envoiText;
+        return $this;
+    }
+
+    public function getConfirmationText()
+    {
+        return $this->_confirmationText;
+    }
+
+    public function setConfirmationText($confirmationText)
+    {
+        $this->_confirmationText = $confirmationText;
+        return $this;
+    }
+
+    public function getAdmin()
+    {
+        return $this->_admin;
+    }
+
+
+    public function setAdmin($admin = true)
+    {
+        $this->_admin = $admin;
+        if ($admin) {
+            $this->addClass('admin');
+        } else {
+            $this->removeClass('admin');
+        }
+        return $this;
+    }
+
+    public function getStatus()
+    {
+        return $this->_status;
+    }
+
+    public function setStatus($status)
+    {
+        $this->_status = $status;
+        $this->_initFields();
+        return $this;
+    }
+
+    protected function _initFields()
+    {
+        $this->_setAdminInfos();
+        $this->_setMagasins();
+        $this->_setCoordonnees();
+        $this->_setDemandes();
+        $this->_setFichiers();
+        $this->_setLivraison();
+        $this->_setAdminReponse();
+        $this->_setEnvoyer();
+
+        $this->_initList();
+    }
+
+    protected function _initList()
+    {
+        $this->setNewTitle(null);
+        $this->setEditTitle('Editer le devis $id');
+        $this->setListTitle('Gestion des devis');
+        $this->setBaseTable('devis_view');
+        $this->setWriteTable('devis');
+        $this->setIdColumn('id');
+        $this->setTitleColumn('societe');
+        $this->setPerPage(30);
+        $this->setAdditionnalColumns(array('email', 'Prix TTC' => '_montant_ttc', 'status', 'Date' => 'date_action', '' => 'type', 'magasin'));
+        $this->setEditLinkTemplate(array('helper' => 'link', 'url' => '/admin/devis/%s'));
+        $this->setAdditionnalActions(array(
+                array($this, '_actionDone'),
+                array($this, '_actionDownload'),
+                array($this, '_actionDuplicate'),
+                array($this, '_actionStore'),
+                array($this, '_actionDocument')
+            )
+        );
+        $this->setAdmin();
+
+        if ($this->getElement('nom') == null) {
+            $this->_initFields();
+        }
+    }
+
+    public function getValueForDisplay($name, $r = null, $view = null)
+    {
+        if ($name == '_montant_ttc') {
+            if ($this->getValue('status') == 0) {
+                return '-';
+            }
+            return number_format($this->details->getValue('montant_ttc'), 2, ',', '&nbsp;');
+        } else if ($name == 'date_action') {
+            $date = new CubeIT_Date($r[$name], CubeIT_Date::MYSQL);
+            return $date->toString('dd-MM-y HH:mm');
+        }
+
+        return parent::getValueForDisplay($name);
+    }
+
+    protected function _actionDuplicate($r, $view)
+    {
+        if ($r['status'] < 1) {
+            return;
+        }
+        return $view->linkAjax($view->imageSilk('page_copy'), '/admin/ajax/devisDuplicate/' . $r['id'], array('title' => 'Dupliquer ce devis', 'target' => '_blank'));
+    }
+
+    protected function _actionStore($r, $view)
+    {
+        if ($r['status'] > 1) {
+            return;
+        }
+        return $view->linkPopup($view->imageSilk('cart'), '/admin/ajaxpopup/devisConvertToStoreOrder/' . $r['id'], array('title' => 'Convertir en facture magasin'));
+    }
+
+    protected function _actionDone($r, $view)
+    {
+        if ($r['status'] != 2) {
+            return;
+        }
+        return $view->linkPopup($view->imageSilk('tick'), '/admin/ajaxpopup/devisDone/' . $r['id'], array('title' => 'Marquer comme terminé'));
+    }
+
+
+    protected function _actionDownload($r, $view)
+    {
+        if (!$r['fichiers']) {
+            return;
+        }
+        return $view->link($view->imageSilk('attach'), '/admin/devisDownload/' . $r['id'], array('title' => 'Télécharger les pièces jointes'));
+    }
+
+    protected function _actionDocument($r, $view)
+    {
+        if ($r['status'] < 1) {
+            return;
+        }
+        $title = 'Voir le devis';
+        $img = 'page_red';
+        if ($r['status'] == 2 || $r['status'] == 5) {
+            $title = 'Voir la facture';
+            $img = 'page_green';
+        }
+        return $view->link($view->imageSilk($img), '/devis/index/' . $r['id'] . '/' . $r['secret'], array('title' => $title, 'target' => '_blank'));
+    }
+
+    public function setDefaults(array $defaults)
+    {
+        if ($this->getElement('nom') == null) {
+            $this->_initFields();
+        }
+
+        return @parent::setDefaults($defaults);
+    }
+
+    public function isValid($data)
+    {
+        if ($this->getElement('nom') == null) {
+            $this->_initFields();
+        }
+        return parent::isValid($data);
+    }
+
+    public function render(Zend_View_Interface $view = null)
+    {
+        if ($this->getElement('nom') == null) {
+            $this->_initFields();
+        }
+
+        if ($this->getAdmin()) {
+            $d = $this->getSubForm('details');
+
+            if (null != $d) {
+                if ($d->isEmpty()) {
+                    $demandes = $this->getSubForm('demandes');
+                    $demandes = $demandes->getTextes();
+                    $details = array();
+
+                    foreach ($demandes as $k => $d) {
+                        $details['descriptif_' . $k] = $d;
+                    }
+
+                    $this->getSubForm('details')->setDefaults($details);
+                }
+                $this->removeSubForm('demandes');
+            }
+        }
+
+        if (!$this->getValue('livraison')) {
+            $this->removeElement('adresse_livraison');
+            $this->removeElement('complement_livraison');
+        }
+
+        return parent::render($view);
+    }
+
+    public function deleteItem($id)
+    {
+        $this->_initList();
+        parent::deleteItem($id);
+    }
+
+    protected function _setMagasins()
+    {
+        $validator = new Zend_Validate_NotEmpty();
+        $validator->setMessage('Veuillez choisir un magasin');
+
+        $mags = DTLC_Util::getMagasins();
+        $options = array();
+        foreach ($mags as $m) {
+            $options[$m['id']] = $m['nom'];
+        }
+
+        $magasins = new Zend_Form_Element_Radio('magasin');
+        $magasins->setRegisterInArrayValidator(false);
+        if ($this->getAdmin()) {
+            $magasins->setLabel('Magasin');
+        }
+        $magasins->setRequired(true);
+        $magasins->setMultiOptions($options);
+        $magasins->clearValidators();
+        $magasins->addValidator($validator);
+        $this->addElement($magasins);
+
+        $legend = $this->getAdmin() ? 'Magasin' : 'Choix du magasin*';
+        $this->addDisplayGroup(array('magasin'), 'magasins_group', array('legend' => $legend));
+    }
+
+    protected function _setCoordonnees()
+    {
+
+        $notEmptyValidator = new Zend_Validate_NotEmpty();
+        $notEmptyValidator->setMessage('Ce champ est obligatoire', Zend_Validate_NotEmpty::IS_EMPTY);
+        $notEmptyValidator->zfBreakChainOnFailure = true;
+
+        $emailValidator = new Zend_Validate_EmailAddress();
+        $emailValidator->setMessage('Cette adresse est invalide', Zend_Validate_EmailAddress::INVALID_FORMAT);
+        $emailValidator->setMessage('Cette adresse est invalide', Zend_Validate_EmailAddress::INVALID_HOSTNAME);
+        $emailValidator->zfBreakChainOnFailure = true;
+
+        $societe = new Zend_Form_Element_Text('societe');
+        $societe->setLabel('Société');
+        $this->addElement($societe);
+
+        $prenom = new Zend_Form_Element_Text('prenom');
+        $prenom->setLabel('Prenom');
+        $prenom->setRequired(true);
+        $prenom->addValidator($notEmptyValidator);
+        $this->addElement($prenom);
+
+        $nom = new Zend_Form_Element_Text('nom');
+        $nom->setLabel('Nom');
+        $nom->setRequired(true);
+        $nom->addValidator($notEmptyValidator);
+        $this->addElement($nom);
+
+        $telephone = new CubeIT_Form_Element_Phone('telephone');
+        $telephone->setLabel('Téléphone');
+        $telephone->setRequired(true);
+        $telephone->addValidator($notEmptyValidator);
+        $this->addElement($telephone);
+
+        $mobile = new CubeIT_Form_Element_Phone('mobile');
+        $mobile->setLabel('Mobile');
+        $this->addElement($mobile);
+
+        $email = new CubeIT_Form_Element_Email('email');
+        $email->setLabel(__('Email'));
+        $email->setRequired(true);
+        $email->clearValidators();
+        $email->addValidator($notEmptyValidator, true);
+        $email->addValidator($emailValidator, true);
+        $this->addElement($email);
+
+        $adresse = new Zend_Form_Element_Textarea('adresse');
+        $adresse->setLabel('Adresse de facturation');
+        $adresse->setAttrib('rows', 2);
+        $adresse->setRequired(true);
+        $adresse->clearValidators();
+        $adresse->addValidator($notEmptyValidator, true);
+        $this->addElement($adresse);
+
+        $codepostal = new Zend_Form_Element_Text('code_postal');
+        $codepostal->setLabel(__('Code postal'));
+        $codepostal->setRequired(true);
+        $codepostal->clearValidators();
+        $codepostal->addValidator($notEmptyValidator, true);
+        $this->addElement($codepostal);
+
+        $ville = new Zend_Form_Element_Text('ville');
+        $ville->setLabel(__('Ville'));
+        $ville->setRequired(true);
+        $ville->clearValidators();
+        $ville->addValidator($notEmptyValidator, true);
+        $this->addElement($ville);
+
+        $pays = new CubeIT_Form_Element_Country('pays');
+        $pays->setLabel(__('Pays'));
+        $pays->setRequired(true);
+        $pays->setDetectCountry(false);
         $pays->setValue('FR');
-               $this->addElement($pays);
-
-               $tva_intra = new Zend_Form_Element_Text('tva_intra');
-               $tva_intra->setLabel(__('N° de TVA'));
-               $tva_intra->clearValidators();
-               $tva_intra->addValidator(new CubeIT_Validate_VATEurope(), true);
-               $this->addElement($tva_intra);
-
-               $reference = new Zend_Form_Element_Text('reference');
-               $reference->setLabel(__('Référence dossier (facultatif)'));
-               $this->addElement($reference);
-
-               $legend = $this->getAdmin() ? 'Coordonnées' : 'Vos coordonnées';
-               $this->addDisplayGroup(array('societe', 'prenom', 'nom', 'telephone', 'mobile', 'email', 'reference', 'adresse', 'code_postal', 'ville', 'pays', 'tva_intra'), 'coordonnees', array('legend' => $legend));
-       }
-
-       protected function _setDemandes() {
-               $demandes = new DTLC_Form_Devis_Demandes();
-               if ($this->getAdmin()) {
-                       $demandes->setLegend('Demandes');
-               } else {
-                       $demandes->setLegend('Vos demandes');
-               }
-               $demandes->setAdmin($this->getAdmin());
-               $this->addSubForm($demandes, 'demandes');
-       }
-
-       protected function _setAdminInfos() {
-               if ($this->getAdmin()) {
-                       $this->setAction('/admin/ajax/devis');
-
-                       $id = new CubeIT_Form_Element_Id();
-                       $this->addElement($id);
-
-                       $date = new CubeIT_Form_Element_Date('date');
-                       $date->setLabel('Date');
-                       $date->setAttrib('disabled', 'disabled');
-                       $date->setPrecision(Zend_Date::MINUTE);
-                       $date->setDisplayFormat(Zend_Date::DATETIME_SHORT);
-                       $this->addElement($date);
-
-                       $status = new Zend_Form_Element_Select('status');
-                       $status->setLabel('Status');
-                       $status->setMultiOptions(array(self::ATTENTE_REPONSE => 'En attente de réponse', self::ATTENTE_PAIEMENT => 'Répondu, en attente de paiement', self::PAYE => 'Payé', self::ANNULE => 'Annulé', self::DONE => 'Payé et terminé'));
-                       $this->addElement($status);
-
-                       $this->addDisplayGroup(array('id', 'status', 'date'), 'group_infos', array('legend' => 'Demande de devis'));
-               }
-       }
-
-       protected function _setFichiers() {
-               $fichiers = new CubeIT_Form_Element_File('fichiers');
-               $fichiers->clearValidators();
-               $fichiers->setRequired(false);
-               $fichiers->setAttrib('data-download', $this->getAdmin());
-               $fichiers->setAttrib('data-dir', 'userfiles');
-               $fichiers->setAttrib('data-admin', 0);
-               $fichiers->setAttrib('data-timecomponent', false);
-               $this->addElement($fichiers);
-
-               $legend = $this->getAdmin() ? 'Fichiers joints' : 'Vos fichiers';
-               $this->addDisplayGroup(array('fichiers'), 'fichiers_group', array('legend' => $legend));
-       }
-
-       protected function _setEnvoyer() {
-               $confirmation = new Zend_Form_Element_Hidden('confirmation');
-               $confirmation->setValue($this->getConfirmationText());
-               $this->addElement($confirmation);
-
-               $texte = new CubeIT_Form_Element_Static('texte');
-               if (!$this->getAdmin()) {
-                       $texte->setValue($this->getEnvoiText());
-               } else {
-                       $texte->setValue('<br /><br /><br />');
-               }
-
-               $this->addElement($texte);
-
-               $submit = new Zend_Form_Element_Submit('submit');
-               if (!$this->getAdmin()) {
-                       $submit->setLabel('Envoyer');
-               } else if ($this->getStatus() == self::ATTENTE_REPONSE) {
-                       $submit->setLabel('Envoyer la réponse');
-               } else {
-                       $submit->setLabel('Enregistrer');
-               }
-               $this->addElement($submit);
-
-               $this->addDisplayGroup(array('confirmation', 'texte', 'submit'), 'last');
-       }
-
-       protected function _setLivraison() {
-
-               $livraison = new Zend_Form_Element_Radio('livraison');
-               $livraison->setMultiOptions(array(1 => 'Oui', 0 => 'Non'));
-               $livraison->setValue(0);
-               $this->addElement($livraison);
-
-               $adresseLivraison = new Zend_Form_Element_Textarea('adresse_livraison');
-               $adresseLivraison->setLabel('Adresse de livraison (si différente)');
-               $adresseLivraison->setAttrib('rows', 3);
-               $this->addElement($adresseLivraison);
-
-               $complementLivraison = new Zend_Form_Element_Textarea('complement_livraison');
-               $complementLivraison->setLabel('Digicode, étage, interphone, bâtiment, etc.');
-               $complementLivraison->setAttrib('rows', 2);
-               $this->addElement($complementLivraison);
-
-               $this->addDisplayGroup(array('livraison', 'adresse_livraison', 'complement_livraison'), 'livraison_group', array('legend' => 'Livraison / Expédition'));
-       }
-
-       protected function _setAdminReponse() {
-               if ($this->getAdmin()) {
-                       if ($this->getStatus() >= self::ATTENTE_PAIEMENT) {
-                               $date_reponse = new CubeIT_Form_Element_Date('date_reponse');
-                               $date_reponse->setLabel('Date de la réponse');
-                               $date_reponse->setAttrib('disabled', 'disabled');
-                               $this->addElement($date_reponse);
-                       }
-
-                       $reponse = new DTLC_Form_Element_Markitup_Color('reponse');
-                       $reponse->setLabel('Réponse');
-                       $this->addElement($reponse);
-
-                       $this->addDisplayGroup(array('date_reponse', 'reponse'), 'reponse_group', array('legend' => 'Réponse DTLC'));
-
-
-                       $details = new DTLC_Form_Devis_Reponses();
-                       $details->setTVA($this->getValue('tva'));
-                       $details->setLegend('Détails de l\'offre');
-                       $this->addSubForm($details, 'details');
-
-                       if ($this->getStatus() >= self::ATTENTE_PAIEMENT) {
-                               $date = new CubeIT_Form_Element_Date('date_paiement');
-                               $date->setLabel('Date du paiement');
-                               $date->setAttrib('disabled', 'disabled');
-                               $this->addElement($date);
-
-                               $infos = new Zend_Form_Element_Textarea('infos_paiement');
-                               $infos->setLabel('Informations sur le paiement');
-                               $this->addElement($infos);
-
-                               $this->addDisplayGroup(array('date_paiement', 'infos_paiement'), 'paiement_group', array('legend' => 'Paiement'));
-                       }
-               }
-       }
+        $this->addElement($pays);
+
+        $tva_intra = new Zend_Form_Element_Text('tva_intra');
+        $tva_intra->setLabel(__('N° de TVA'));
+        $tva_intra->clearValidators();
+        $tva_intra->addValidator(new CubeIT_Validate_VATEurope(), true);
+        $this->addElement($tva_intra);
+
+        $reference = new Zend_Form_Element_Text('reference');
+        $reference->setLabel(__('Référence dossier (facultatif)'));
+        $this->addElement($reference);
+
+        $legend = $this->getAdmin() ? 'Coordonnées' : 'Vos coordonnées';
+        $this->addDisplayGroup(array('societe', 'prenom', 'nom', 'telephone', 'mobile', 'email', 'reference', 'adresse', 'code_postal', 'ville', 'pays', 'tva_intra'), 'coordonnees', array('legend' => $legend));
+    }
+
+    protected function _setDemandes()
+    {
+        $demandes = new DTLC_Form_Devis_Demandes();
+        if ($this->getAdmin()) {
+            $demandes->setLegend('Demandes');
+        } else {
+            $demandes->setLegend('Vos demandes');
+        }
+        $demandes->setAdmin($this->getAdmin());
+        $this->addSubForm($demandes, 'demandes');
+    }
+
+    protected function _setAdminInfos()
+    {
+        if ($this->getAdmin()) {
+            $this->setAction('/admin/ajax/devis');
+
+            $id = new CubeIT_Form_Element_Id();
+            $this->addElement($id);
+
+            $date = new CubeIT_Form_Element_Date('date');
+            $date->setLabel('Date');
+            $date->setAttrib('disabled', 'disabled');
+            $date->setPrecision(Zend_Date::MINUTE);
+            $date->setDisplayFormat(Zend_Date::DATETIME_SHORT);
+            $this->addElement($date);
+
+            $status = new Zend_Form_Element_Select('status');
+            $status->setLabel('Status');
+            $status->setMultiOptions(array(self::ATTENTE_REPONSE => 'En attente de réponse', self::ATTENTE_PAIEMENT => 'Répondu, en attente de paiement', self::PAYE => 'Payé', self::ANNULE => 'Annulé', self::DONE => 'Payé et terminé'));
+            $this->addElement($status);
+
+            $type = new Zend_Form_Element_Select('type');
+            $type->setLabel('Type de commande');
+            $type->setMultiOptions(['NET' => 'Internet', 'MAG' => 'Magasin']);
+            $type->setValue('NET');
+            $this->addElement($type);
+
+            $this->addDisplayGroup(array('id', 'status', 'date', 'type'), 'group_infos', array('legend' => 'Demande de devis'));
+        }
+    }
+
+    protected function _setFichiers()
+    {
+        $fichiers = new CubeIT_Form_Element_File('fichiers');
+        $fichiers->clearValidators();
+        $fichiers->setRequired(false);
+        $fichiers->setAttrib('data-download', $this->getAdmin());
+        $fichiers->setAttrib('data-dir', 'userfiles');
+        $fichiers->setAttrib('data-admin', 0);
+        $fichiers->setAttrib('data-timecomponent', false);
+        $this->addElement($fichiers);
+
+        $legend = $this->getAdmin() ? 'Fichiers joints' : 'Vos fichiers';
+        $this->addDisplayGroup(array('fichiers'), 'fichiers_group', array('legend' => $legend));
+    }
+
+    protected function _setEnvoyer()
+    {
+        $confirmation = new Zend_Form_Element_Hidden('confirmation');
+        $confirmation->setValue($this->getConfirmationText());
+        $this->addElement($confirmation);
+
+        $texte = new CubeIT_Form_Element_Static('texte');
+        if (!$this->getAdmin()) {
+            $texte->setValue($this->getEnvoiText());
+        } else {
+            $texte->setValue('<br /><br /><br />');
+        }
+
+        $this->addElement($texte);
+
+        $submit = new Zend_Form_Element_Submit('submit');
+        if (!$this->getAdmin()) {
+            $submit->setLabel('Envoyer');
+        } else if ($this->getStatus() == self::ATTENTE_REPONSE) {
+            $submit->setLabel('Envoyer la réponse');
+        } else {
+            $submit->setLabel('Enregistrer');
+        }
+        $this->addElement($submit);
+
+        $this->addDisplayGroup(array('confirmation', 'texte', 'submit'), 'last');
+    }
+
+    protected function _setLivraison()
+    {
+
+        $livraison = new Zend_Form_Element_Radio('livraison');
+        $livraison->setMultiOptions(array(1 => 'Oui', 0 => 'Non'));
+        $livraison->setValue(0);
+        $this->addElement($livraison);
+
+        $adresseLivraison = new Zend_Form_Element_Textarea('adresse_livraison');
+        $adresseLivraison->setLabel('Adresse de livraison (si différente)');
+        $adresseLivraison->setAttrib('rows', 3);
+        $this->addElement($adresseLivraison);
+
+        $complementLivraison = new Zend_Form_Element_Textarea('complement_livraison');
+        $complementLivraison->setLabel('Digicode, étage, interphone, bâtiment, etc.');
+        $complementLivraison->setAttrib('rows', 2);
+        $this->addElement($complementLivraison);
+
+        $this->addDisplayGroup(array('livraison', 'adresse_livraison', 'complement_livraison'), 'livraison_group', array('legend' => 'Livraison / Expédition'));
+    }
+
+    protected function _setAdminReponse()
+    {
+        if ($this->getAdmin()) {
+            if ($this->getStatus() >= self::ATTENTE_PAIEMENT) {
+                $date_reponse = new CubeIT_Form_Element_Date('date_reponse');
+                $date_reponse->setLabel('Date de la réponse');
+                $date_reponse->setAttrib('disabled', 'disabled');
+                $this->addElement($date_reponse);
+            }
+
+            $reponse = new DTLC_Form_Element_Markitup_Color('reponse');
+            $reponse->setLabel('Réponse');
+            $this->addElement($reponse);
+
+            $this->addDisplayGroup(array('date_reponse', 'reponse'), 'reponse_group', array('legend' => 'Réponse DTLC'));
+
+
+            $details = new DTLC_Form_Devis_Reponses();
+            $details->setTVA($this->getValue('tva'));
+            $details->setLegend('Détails de l\'offre');
+            $this->addSubForm($details, 'details');
+
+            if ($this->getStatus() >= self::ATTENTE_PAIEMENT) {
+                $payment_method = new Zend_Form_Element_Select('methode_paiement');
+                $payment_method->setLabel('Moyen de paiement');
+                $payment_method->setMultiOptions(['SOGENACTIF' => 'Sogenactif', 'CB' => 'Carte bancaire', 'ESPECES' => 'Espèces', 'CHEQUE' => 'Chèque', 'VIREMENT' => 'Virement']);
+                $payment_method->setValue('SOGENACTIF');
+                $this->addElement($payment_method);
+
+                $date = new CubeIT_Form_Element_Date('date_paiement');
+                $date->setLabel('Date du paiement');
+                $date->setAttrib('disabled', 'disabled');
+                $this->addElement($date);
+
+                $infos = new Zend_Form_Element_Textarea('infos_paiement');
+                $infos->setLabel('Informations sur le paiement');
+                $this->addElement($infos);
+
+                $this->addDisplayGroup(array('methode_paiement', 'date_paiement', 'infos_paiement'), 'paiement_group', array('legend' => 'Paiement'));
+            }
+        }
+    }
 
 }
index f663ccd950483f85568bfdff5860f8eae315f0c8..f28a4ae5ed3f0d5977c8f5f247bda3e6f794d2df 100644 (file)
@@ -3,14 +3,14 @@
 $this->headScript()->addScriptAndStyle('devis/voir');
 //$this->headLink()->appendStylesheet('/less/devis/print.less'/*, 'print'*/);
 if ($this->print) {
-       $this->headScript()->addScriptAndStyle('devis/print');
+    $this->headScript()->addScriptAndStyle('devis/print');
 }
 
 $isFacture = in_array($this->devis->status, array(2, 5));
 if (!$isFacture && $this->devis->reponse) {
-       echo '<div class="box">';
-       echo $this->markupDotclear($this->devis->reponse);
-       echo '</div>';
+    echo '<div class="box">';
+    echo $this->markupDotclear($this->devis->reponse);
+    echo '</div>';
 }
 
 
@@ -22,34 +22,34 @@ echo '<div class="top">';
 echo '<address>';
 echo '<strong>';
 if ($this->devis->societe) {
-       echo $this->devis->societe . '<br />';
+    echo $this->devis->societe . '<br />';
 } else {
-       echo $this->devis->prenom . ' ' . $this->devis->nom . '<br />';
+    echo $this->devis->prenom . ' ' . $this->devis->nom . '<br />';
 }
 echo '</strong>';
 if ($this->devis->adresse) {
-       echo nl2br(trim($this->devis->adresse)) . '<br />';
+    echo nl2br(trim($this->devis->adresse)) . '<br />';
 }
 if ($this->devis->code_postal && $this->devis->ville) {
-       echo $this->devis->code_postal . ' ' . $this->devis->ville . '<br />';
+    echo $this->devis->code_postal . ' ' . $this->devis->ville . '<br />';
 }
 if ($this->devis->country != 'FR') {
-       echo Zend_Locale::getTranslation($this->devis->country, 'territory') . "<br />";
+    echo Zend_Locale::getTranslation($this->devis->country, 'territory') . "<br />";
 }
 if ($this->devis->tva_intra) {
-       echo '<br /><span class="small">N° de TVA : ' . $this->devis->tva_intra . '</span>';
+    echo '<br /><span class="small">N° de TVA : ' . $this->devis->tva_intra . '</span>';
 }
 echo '</address>';
 
 
 if ($isFacture) {
-       $date = new Zend_Date($this->devis->date_paiement);
-       echo '<h2>Facture ' . DTLC_Util::getInvoiceNumber($this->devis) . '</h2>';
-       echo '<h3>le ' . $date->toString('d MMMM y') . '</h3>';
+    $date = new Zend_Date($this->devis->date_paiement);
+    echo '<h2>Facture ' . DTLC_Util::getInvoiceNumber($this->devis) . '</h2>';
+    echo '<h3>le ' . $date->toString('d MMMM y') . '</h3>';
 } else {
-       $date = new Zend_Date($this->devis->date_reponse);
-       echo '<h2>Devis ' . DTLC_Util::getQuoteNumber($this->devis) . '</h2>';
-       echo '<h3>le ' . $date->toString('d MMMM y') . '</h3>';
+    $date = new Zend_Date($this->devis->date_reponse);
+    echo '<h2>Devis ' . DTLC_Util::getQuoteNumber($this->devis) . '</h2>';
+    echo '<h3>le ' . $date->toString('d MMMM y') . '</h3>';
 }
 
 
@@ -58,7 +58,7 @@ echo 'Contact : ' . $this->devis->prenom . ' ' . $this->devis->nom;
 echo ' / ' . $this->devis->telephone;
 echo '<br />';
 if ($this->devis->reference) {
-       echo 'Référence : ' . nl2br(trim($this->devis->reference));
+    echo 'Référence : ' . nl2br(trim($this->devis->reference));
 }
 echo '</div>';
 echo '</div>';
@@ -70,20 +70,20 @@ echo '</thead>';
 echo '<tbody>';
 
 foreach ($this->details as $k => $line) {
-       if (trim(implode($line)) == '') {
-               continue;
-       }
-       $line['prix'] = trim($line['prix']);
-
-       echo '<tbody>';
-       echo '<tr><td class="p"></td></tr>';
-       echo '<tr><td class="descriptif" colspan="2">' . $this->markupDotclear(trim($line['descriptif']), array('markup' => '', 'class' => '')) . '</td>';
-       echo '<td class="r">';
-       if ($line['prix'] != '') {
-               echo number_format($line['prix'], 2, ',', '') . ' €';
-       }
-       echo '</td></tr>';
-       echo '</tbody>';
+    if (trim(implode($line)) == '') {
+        continue;
+    }
+    $line['prix'] = trim($line['prix']);
+
+    echo '<tbody>';
+    echo '<tr><td class="p"></td></tr>';
+    echo '<tr><td class="descriptif" colspan="2">' . $this->markupDotclear(trim($line['descriptif']), array('markup' => '', 'class' => '')) . '</td>';
+    echo '<td class="r">';
+    if ($line['prix'] != '') {
+        echo number_format($line['prix'], 2, ',', '') . ' €';
+    }
+    echo '</td></tr>';
+    echo '</tbody>';
 }
 
 
@@ -95,8 +95,17 @@ echo '<tr><td class="p"></td></tr>';
 
 $paiement = '';
 if ($isFacture) {
-       $date = new CubeIT_Date($this->devis->date_paiement, CubeIT_Date::MYSQL);
-       $paiement = 'Paiement par CB le ' . $date->toString('dd/MM/Y');
+    $date = new CubeIT_Date($this->devis->date_paiement, CubeIT_Date::MYSQL);
+
+    $texts = [
+        'SOGENACTIF' => 'Paiement par CB (Web) le ',
+        'CB' => 'Paiement par CB le ',
+        'ESPECES' => 'Paiement en espèces le ',
+        'CHEQUE' => 'Paiement par chèque le ',
+        'VIREMENT' => 'Paiement par virement le ',
+    ];
+
+    $paiement = $texts[$this->devis->methode_paiement ?: 'SOGENACTIF'] . $date->toString('dd/MM/Y');
 }
 
 echo '<tr><td rowspan="3" id="paiement">' . $paiement . '</td> <td class="t">Total HT</td><td class="r">' . number_format($this->ht, 2, ',', '') . ' €</td></tr>';
@@ -109,15 +118,15 @@ echo '</table>';
 $printurl = '/devis/print/' . $this->devis->id . '/' . $this->devis->secret;
 
 if (!$isFacture) {
-       echo '<a id="print" target="_blank" href="' . $printurl . '">Imprimer le devis</a>';
+    echo '<a id="print" target="_blank" href="' . $printurl . '">Imprimer le devis</a>';
 } else {
-       echo '<a id="print" target="_blank" href="' . $printurl . '">Imprimer la facture</a>';
+    echo '<a id="print" target="_blank" href="' . $printurl . '">Imprimer la facture</a>';
 }
 echo '<footer>';
 if ($isFacture) {
-       echo '<div class="legal">' . $this->markupDotclear($this->option('legal_facture')) . "</div>";
+    echo '<div class="legal">' . $this->markupDotclear($this->option('legal_facture')) . "</div>";
 } else {
-       echo '<div class="legal">' . $this->markupDotclear($this->option('legal_devis')) . "</div>";
+    echo '<div class="legal">' . $this->markupDotclear($this->option('legal_devis')) . "</div>";
 }
 echo '</footer>';
 echo '</div>';
@@ -126,11 +135,11 @@ echo '</div>';
 echo '</div>';
 
 if (!$isFacture && $this->paymentForm) {
-       echo '<div class="box">';
-       echo '<h3>Payer en ligne grâce au paiement sécurisé Sogenactif</h3><br>';
-       // echo '<div style="display: none;">' . $this->paymentForm1 . '</div>';
-       echo $this->paymentForm;
+    echo '<div class="box">';
+    echo '<h3>Payer en ligne grâce au paiement sécurisé Sogenactif</h3><br>';
+    // echo '<div style="display: none;">' . $this->paymentForm1 . '</div>';
+    echo $this->paymentForm;
     echo $this->paymentAddForm;
-       echo '</div>';
+    echo '</div>';
 }
 
diff --git a/framework/library/CubeIT/Mail/Transport/Postal.php b/framework/library/CubeIT/Mail/Transport/Postal.php
new file mode 100644 (file)
index 0000000..b9df141
--- /dev/null
@@ -0,0 +1,32 @@
+<?php
+
+class CubeIT_Mail_Transport_Postal extends Zend_Mail_Transport_Smtp
+{
+
+    public function __construct($user = null, $password = null)
+    {
+
+        if (null === $user || null === $password) {
+            $bootstrap = Bootstrap::getInstance();
+            $postal = $bootstrap->getOpt("postal", array());
+
+            if (null === $user && isset($postal['username'])) {
+                $user = $postal['username'];
+            }
+            if (null === $password && isset($postal['password'])) {
+                $password = $postal['password'];
+            }
+        }
+
+        $config = array(
+            'port' => 25,
+            'auth' => 'plain',
+            'username' => $user,
+            'password' => $password,
+            'ssl' => 'tls');
+
+        parent::__construct($postal['server'], $config);
+    }
+
+}
+