]> _ Git - cubeextranet.git/commitdiff
(no commit message)
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Tue, 21 Feb 2012 10:33:54 +0000 (10:33 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Tue, 21 Feb 2012 10:33:54 +0000 (10:33 +0000)
inc/extranet/Controlleur/class.extranet.ajax.php
inc/extranet/Controlleur/class.extranet.url.php
inc/extranet/DAO/class.extranet.dao.facture.php
style/extranet/style.css

index 6b8f2b02e58987db556d7cea7f69acbde6020cd8..8d90b23f21ab774cbed413a1b07ce330515d48d6 100644 (file)
@@ -384,6 +384,7 @@ class extranetAjax {
                }\r
                // On marque le devis comme envoyé\r
                $dao->changeStatus($devis->devis_id, 1);\r
+               $x->addDownloadFile('/voirdevis/' . $devis->devis_id . '/1');\r
                $x->addRedirection(SITE_PATH . 'devis');\r
        }\r
 \r
@@ -428,6 +429,7 @@ class extranetAjax {
                $dao = new extranetDAOFacture($core->con);\r
                $dao->valide($args[1]);\r
 \r
+               $x->addTruePopup('/voirfacture/' . $args[1]);\r
                $x->addRedirection(SITE_PATH . 'factures');\r
        }\r
 \r
@@ -568,8 +570,8 @@ class extranetAjax {
        public static function chargesDetails($args, &$x) {\r
                commonAjax::form('', sprintf(__("Détails des charges de l'année %s"), date('Y')), extranetPageChiffres::chargesDetails($args), '', 3, 'liste');\r
        }\r
-       \r
-       public static function makeFavicon($args,&$x){\r
+\r
+       public static function makeFavicon($args, &$x) {\r
                $x->addRedirection(extranetTools::makeFavicon());\r
        }\r
 \r
index fadc330ea3fa0252768e788b13b3cff09703a0d1..061109043070f01c7782a7c7fd7eab490dab2e94 100644 (file)
@@ -930,9 +930,15 @@ class extranetUrl {
                // Charge le devis\r
                $dao = new extranetDAODevis($core->con);\r
                $devis = $dao->selectById($args[1]);\r
+\r
+               $forceDownload = isset($args[2]) && $args[2];\r
+\r
                // Vérification des droits en lecture de l'utilisateur\r
                extranetDroits::devis($devis, 'r');\r
 \r
+               if ($forceDownload) {\r
+                       cubeHTTP::forceDownload('Devis_' . $args[1] . '.pdf');\r
+               }\r
                cubeHTTP::relayNoCache(ROOT . '/devis/' . $args[1] . '.pdf');\r
        }\r
 \r
@@ -1455,9 +1461,9 @@ class extranetUrl {
 \r
                $res .= '<div class="right">' . '<a href="' . SITE_PATH . 'editefacture/' . $facture->facture_id . '">' . $core->typo->BoutonOK(__('Editer la facture')) . '</a> ';\r
                if ($facture->status == 0) {\r
-                       $res .= '<a href="#" rel="valideFacture/' . $facture->facture_id . '" class="ajax" title="' . __("La facture est sur le point d'être validée. Elle ne sera plus éditable. Veuillez confirmer votre choix ?") . '">' . $core->typo->BoutonOK(__('Valider la facture')) . '</a>';\r
+                       $res .= '<a href="#" rel="valideFacture/' . $facture->facture_id . '" class="ajax" title="' . __("La facture est sur le point d'être validée. Veuillez confirmer votre choix ?") . '">' . $core->typo->BoutonOK(__('Valider la facture')) . '</a>';\r
                } else {\r
-                       $res .= '<a href="' . SITE_PATH . 'factures">' . $core->typo->BoutonOK(__('Valider la facture')) . '</a>';\r
+                       $res .= '<a href="#" rel="valideFacture/' . $facture->facture_id . '" class="ajax">' . $core->typo->BoutonOK(__('Valider la facture')) . '</a>';\r
                }\r
                $res .= '</div>';\r
                $res .= commonPage::bf();\r
@@ -1595,8 +1601,6 @@ class extranetUrl {
                return $res;\r
        }\r
 \r
-\r
-\r
 }\r
 \r
 ?>
\ No newline at end of file
index 433e7fd58f4f44f7b6fe445c9ea092afe37cd570..77c4d8cf749f16c78f9782a8a23ee7524426b615 100644 (file)
@@ -1,4 +1,5 @@
 <?php\r
+\r
 /**\r
  * extranetDAOFacture\r
  *\r
@@ -9,8 +10,8 @@
  * @access public\r
  */\r
 class extranetDAOFacture extends commonDAO {\r
-       protected function singleton($r)\r
-       {\r
+\r
+       protected function singleton($r) {\r
                $facture = new extranetFacture();\r
                $facture->facture_id = $r->facture_id;\r
                $facture->nom = $r->nom;\r
@@ -32,8 +33,7 @@ class extranetDAOFacture extends commonDAO {
                return $facture;\r
        }\r
 \r
-       public function cree()\r
-       {\r
+       public function cree() {\r
                $facture = new extranetFacture();\r
                $facture->facture_id = 'new';\r
                $facture->nom = '';\r
@@ -55,14 +55,12 @@ class extranetDAOFacture extends commonDAO {
                return $facture;\r
        }\r
 \r
-       public function selectById($facture_id)\r
-       {\r
+       public function selectById($facture_id) {\r
                $r = $this->con->select('SELECT * FROM factures_vue WHERE facture_id=\'' . $this->con->escape($facture_id) . '\'');\r
                return $this->singleton($r);\r
        }\r
 \r
-       public function getListe($orderby = null, $sens = null, $limit = null)\r
-       {\r
+       public function getListe($orderby = null, $sens = null, $limit = null) {\r
                if (!is_null($this->q)) {\r
                        $where = '';\r
                        if ($this->search_id) {\r
@@ -76,9 +74,9 @@ class extranetDAOFacture extends commonDAO {
                        $where = $this->makeWhereFromFiltres();\r
                }\r
 \r
-               $orderby = is_null($orderby)?'facture_id':$orderby;\r
-               $sens = is_null($sens)?'DESC':$sens;\r
-               $limit = is_null($limit)?'':$this->con->limit($limit[0], $limit[1]);\r
+               $orderby = is_null($orderby) ? 'facture_id' : $orderby;\r
+               $sens = is_null($sens) ? 'DESC' : $sens;\r
+               $limit = is_null($limit) ? '' : $this->con->limit($limit[0], $limit[1]);\r
 \r
                $sql = 'SELECT * FROM factures_vue WHERE ' . $where . ' ORDER BY ' . $orderby . ' ' . $sens . ' ' . $limit;\r
                fb($sql);\r
@@ -86,8 +84,7 @@ class extranetDAOFacture extends commonDAO {
                return $this->factory($r);\r
        }\r
 \r
-       public function getListeCompta($orderby = null, $sens = null, $limit = null)\r
-       {\r
+       public function getListeCompta($orderby = null, $sens = null, $limit = null) {\r
                if (!is_null($this->q)) {\r
                        $where = '';\r
                        if ($this->search_id) {\r
@@ -101,46 +98,41 @@ class extranetDAOFacture extends commonDAO {
                        $where = $this->makeWhereFromFiltres();\r
                }\r
 \r
-               $orderby = is_null($orderby)?'facture_id':$orderby;\r
-               $sens = is_null($sens)?'DESC':$sens;\r
-               $limit = is_null($limit)?'':$this->con->limit($limit[0], $limit[1]);\r
+               $orderby = is_null($orderby) ? 'facture_id' : $orderby;\r
+               $sens = is_null($sens) ? 'DESC' : $sens;\r
+               $limit = is_null($limit) ? '' : $this->con->limit($limit[0], $limit[1]);\r
 \r
                $sql = 'SELECT * FROM factures_vue WHERE (' . $where . ') AND CAST(facture_id AS SIGNED)>0 ORDER BY ' . $orderby . ' ' . $sens . ' ' . $limit;\r
                $r = $this->con->select($sql);\r
                return $this->factory($r);\r
        }\r
 \r
-       public function getListeForClient($client_id, $orderby, $sens)\r
-       {\r
+       public function getListeForClient($client_id, $orderby, $sens) {\r
                $sql = 'SELECT * FROM factures_vue WHERE client_id=\'' . $this->con->escape($client_id) . '\' AND status>0 ORDER BY ' . $orderby . ' ' . $sens;\r
                $r = $this->con->select($sql);\r
                return $this->factory($r);\r
        }\r
 \r
-       public function getListeForEntreprise($entreprise_id, $orderby, $sens)\r
-       {\r
+       public function getListeForEntreprise($entreprise_id, $orderby, $sens) {\r
                $sql = 'SELECT * FROM factures_vue WHERE client_id IN(SELECT utilisateur_id FROM utilisateurs WHERE entreprise=\'' . $this->con->escape($entreprise_id) . '\') AND status>0 ORDER BY ' . $orderby . ' ' . $sens;\r
                $r = $this->con->select($sql);\r
                return $this->factory($r);\r
        }\r
 \r
-       public function getImpayesOfClient($client_id)\r
-       {\r
+       public function getImpayesOfClient($client_id) {\r
                $sql = 'SELECT * FROM factures_vue WHERE client_id=\'' . $this->con->escape($client_id) . '\' AND status=1 ORDER BY date_creation';\r
                $r = $this->con->select($sql);\r
                return $this->factory($r);\r
        }\r
 \r
-       public function changeStatus($facture_id, $status)\r
-       {\r
+       public function changeStatus($facture_id, $status) {\r
                if ($status == 3) {\r
                        $this->annule($facture_id);\r
                }\r
                return $this->con->execute('UPDATE factures SET status=' . $status . ' WHERE facture_id=\'' . $this->con->escape($facture_id) . '\'');\r
        }\r
 \r
-       public function annule($facture_id)\r
-       {\r
+       public function annule($facture_id) {\r
                $facture = $this->selectById($facture_id);\r
                $avoir = $this->duplique($facture_id, $facture->createur_id, true);\r
                $avoir->facture_id = $this->idBrouillonToIdNormal($avoir->facture_id);\r
@@ -149,8 +141,7 @@ class extranetDAOFacture extends commonDAO {
                $this->saveAsPDF($avoir->facture_id);\r
        }\r
 \r
-       public function setLinkAvoir($id1, $id2)\r
-       {\r
+       public function setLinkAvoir($id1, $id2) {\r
                $c = $this->con->openCursor('factures');\r
                $c->avoir = $id1;\r
                $c->update('WHERE facture_id=\'' . $this->con->escape($id2) . '\'');\r
@@ -158,19 +149,17 @@ class extranetDAOFacture extends commonDAO {
                $c->update('WHERE facture_id=\'' . $this->con->escape($id1) . '\'');\r
        }\r
 \r
-       public function supprime($facture_id)\r
-       {\r
+       public function supprime($facture_id) {\r
                return $this->con->execute('DELETE FROM factures WHERE facture_id=\'' . $this->con->escape($facture_id) . '\'');\r
        }\r
 \r
-       public function getNextId($brouillon = true)\r
-       {\r
+       public function getNextId($brouillon = true) {\r
                if ($brouillon) {\r
                        $r = $this->con->select('SELECT facture_id AS facture_id FROM factures WHERE status=0 ORDER BY facture_id DESC LIMIT 1');\r
                        if (!$r->count()) {\r
                                return 'A';\r
                        } else {\r
-                               return ++$r->facture_id;\r
+                               return++$r->facture_id;\r
                        }\r
                } else {\r
                        $r = $this->con->select('SELECT MAX(CAST(facture_id AS SIGNED)) AS facture_id FROM factures WHERE status>0');\r
@@ -182,10 +171,9 @@ class extranetDAOFacture extends commonDAO {
                }\r
        }\r
 \r
-       public function sauve($data, $createur)\r
-       {\r
+       public function sauve($data, $createur) {\r
                $lignes = array();\r
-               foreach($data['montant'] as $i => $montant) {\r
+               foreach ($data['montant'] as $i => $montant) {\r
                        $ligne = array('titre' => $data['titre'][$i], 'description' => $data['description'][$i], 'montant' => $data['montant'][$i], 'book' => $data['montant'][$i]);\r
                        if ($ligne['titre'] == '' && $ligne['description'] == '' && $ligne['montant'] == '') {\r
                                continue;\r
@@ -200,7 +188,7 @@ class extranetDAOFacture extends commonDAO {
                $c->total_ht = 0;\r
                $c->texte_complementaire = $data['texte_complementaire'];\r
                $c->adresse = $data['adresse'];\r
-               foreach($lignes as $k => $d) {\r
+               foreach ($lignes as $k => $d) {\r
                        $d['montant'] = round(floatval(str_replace(',', '.', $d['montant'])), 2);\r
                        $lignes[$k]['montant'] = $d['montant'];\r
                        $c->total_ht += $d['montant'];\r
@@ -228,7 +216,7 @@ class extranetDAOFacture extends commonDAO {
                                $daoProjet->changeStatus($projet_id);\r
 \r
                                $daoTache = new extranetDAOTache($this->con);\r
-                               foreach($lignes as $ligne) {\r
+                               foreach ($lignes as $ligne) {\r
                                        $ligne['montant'] = round(floatval(str_replace(',', '.', $ligne['montant'])), 2);\r
                                        $m = $ligne['montant'];\r
                                        if (!$m) {\r
@@ -251,7 +239,7 @@ class extranetDAOFacture extends commonDAO {
                        $c->insert();\r
                        // Marque les fluidbook comme facturés\r
                        $books = array();\r
-                       foreach($lignes as $ligne) {\r
+                       foreach ($lignes as $ligne) {\r
                                $books[] = $ligne['book'];\r
                        }\r
                        $cb = $this->con->openCursor('ws.book');\r
@@ -266,8 +254,7 @@ class extranetDAOFacture extends commonDAO {
                return $this->selectById($facture_id);\r
        }\r
 \r
-       public function saveAsPDF($facture_id)\r
-       {\r
+       public function saveAsPDF($facture_id) {\r
                $facture = $this->selectById($facture_id);\r
                $daoUtilisateur = new commonDAOUtilisateur($this->con);\r
                $facture->client = $daoUtilisateur->selectById($facture->client_id);\r
@@ -284,8 +271,7 @@ class extranetDAOFacture extends commonDAO {
                $pdf->Output(ROOT . '/factures/' . $facture->facture_id . '.pdf');\r
        }\r
 \r
-       public function savePaiement($data)\r
-       {\r
+       public function savePaiement($data) {\r
                $c = $this->con->openCursor('factures');\r
                $c->status = 2;\r
                $c->informations_paiement = $data['informations_paiement'];\r
@@ -293,8 +279,7 @@ class extranetDAOFacture extends commonDAO {
                $c->update('WHERE facture_id=\'' . $this->con->escape($data['facture_id']) . '\'');\r
        }\r
 \r
-       public function duplique($facture_id, $createur, $avoir = false)\r
-       {\r
+       public function duplique($facture_id, $createur, $avoir = false) {\r
                $facture = $this->selectById($facture_id);\r
 \r
                $c = $this->con->openCursor('factures');\r
@@ -310,7 +295,7 @@ class extranetDAOFacture extends commonDAO {
                        $c->total_ht = $facture->total_ht;\r
                } else {\r
                        $lignes = array();\r
-                       foreach($facture->lignes as $l) {\r
+                       foreach ($facture->lignes as $l) {\r
                                if (is_numeric($l['montant'])) {\r
                                        $l['montant'] *= -1;\r
                                }\r
@@ -325,14 +310,17 @@ class extranetDAOFacture extends commonDAO {
                return $this->selectById($c->facture_id);\r
        }\r
 \r
-       public function valide($facture_id)\r
-       {\r
-               $new_id = $this->idBrouillonToIdNormal($facture_id);\r
+       public function valide($facture_id) {\r
+               if (intval($facture_id) == 0) {\r
+                       $new_id = $this->idBrouillonToIdNormal($facture_id);\r
+               } else {\r
+                       $new_id = $facture_id;\r
+               }\r
+\r
                return $this->changeStatus($new_id, 1);\r
        }\r
 \r
-       public function idBrouillonToIdNormal($facture_id)\r
-       {\r
+       public function idBrouillonToIdNormal($facture_id) {\r
                $c = $this->con->openCursor('factures');\r
                $c->facture_id = $this->getNextId(false);\r
                $c->status = 1;\r
@@ -344,26 +332,23 @@ class extranetDAOFacture extends commonDAO {
                return $c->facture_id;\r
        }\r
 \r
-       public function count()\r
-       {\r
-               $filters=$this->makeWhereFromFiltres();\r
-               if($filters=='1=1'){\r
-                       $table='factures';\r
-               }else{\r
-                       $table='factures_vue';\r
+       public function count() {\r
+               $filters = $this->makeWhereFromFiltres();\r
+               if ($filters == '1=1') {\r
+                       $table = 'factures';\r
+               } else {\r
+                       $table = 'factures_vue';\r
                }\r
-               $r = $this->con->select('SELECT COUNT(*) AS nb FROM '.$table.' WHERE ' . $filters);\r
+               $r = $this->con->select('SELECT COUNT(*) AS nb FROM ' . $table . ' WHERE ' . $filters);\r
                return $r->nb;\r
        }\r
 \r
-       public function countCompta()\r
-       {\r
+       public function countCompta() {\r
                $r = $this->con->select('SELECT COUNT(*) AS nb FROM factures_vue WHERE (' . $this->makeWhereFromFiltres() . ') AND CAST(facture_id AS SIGNED)>0');\r
                return $r->nb;\r
        }\r
 \r
-       protected function makeWhereFromFiltres()\r
-       {\r
+       protected function makeWhereFromFiltres() {\r
                if (!is_null($this->filtres)) {\r
                        $w = array('1=1');\r
                        if (commonFiltre::test('annee_facture', $this->filtres)) {\r
@@ -380,6 +365,7 @@ class extranetDAOFacture extends commonDAO {
                        return '1=1';\r
                }\r
        }\r
+\r
 }\r
 \r
 ?>
\ No newline at end of file
index 756b12d4856b710588383f8e3357f19d099647fc..bdcbb02f1410869d18296116c7d06202a23b6d67 100644 (file)
@@ -168,6 +168,11 @@ input[type="text"],input[type="password"],input[type="email"],input[type="search
 .devisLigneLeft{width:700px;padding:20px;}\r
 .devisLigneRight{width:120px;float:right;text-align:center;padding:20px;}\r
 \r
+.devisLigneLeft textarea,\r
+.devisLigneLeft input[type="text"]{\r
+       width:700px;\r
+}\r
+\r
 #devisMail{padding:30px;margin-top:30px;border-top:2px solid #000;}\r
 #devisMail td{color:#000 !important;}\r
 \r