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