/[dolibarr]/dolibarr/htdocs/facture.class.php
ViewVC logotype

Diff of /dolibarr/htdocs/facture.class.php

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.122 by marc_ocebo, Thu Sep 15 00:37:03 2005 UTC revision 1.123 by eldy, Sat Oct 1 15:57:05 2005 UTC
# Line 213  class Facture Line 213  class Facture
213                                  }                                  }
214                          }                          }
215    
216              $result=$this->updateprice($this->id);              $resql=$this->updateprice($this->id);
217              if ($result)              if ($resql)
218              {              {
219                  // Appel des triggers                  // Appel des triggers
220                  include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");                  include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
221                  $interface=new Interfaces($this->db);                  $interface=new Interfaces($this->db);
222                  $interface->run_triggers('BILL_CREATE',$this,$user,$lang,$conf);                  $result=$interface->run_triggers('BILL_CREATE',$this,$user,$lang,$conf);
223                  // Fin appel triggers                  // Fin appel triggers
224            
225                  $this->db->commit();                  $this->db->commit();
# Line 603  class Facture Line 603  class Facture
603                                  // Appel des triggers                                  // Appel des triggers
604                                  include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");                                  include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
605                                  $interface=new Interfaces($this->db);                                  $interface=new Interfaces($this->db);
606                                  $interface->run_triggers('BILL_DELETE',$this,$user,$lang,$conf);                                  $result=$interface->run_triggers('BILL_DELETE',$this,$user,$lang,$conf);
607                                  // Fin appel triggers                                  // Fin appel triggers
608                                    
609                                  $this->db->commit();                                  $this->db->commit();
# Line 688  class Facture Line 688  class Facture
688                  return $datelim;                  return $datelim;
689          }          }
690    
   
691          /**          /**
692           *    \brief     Tag la facture comme payée complètement           *    \brief     Tag la facture comme payée complètement
693           *    \param     rowid       id de la facture à modifier           *    \param     rowid       id de la facture à modifier
# Line 696  class Facture Line 695  class Facture
695          function set_payed($rowid)          function set_payed($rowid)
696          {          {
697                  $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture set paye=1 WHERE rowid = '.$rowid ;                  $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture set paye=1 WHERE rowid = '.$rowid ;
698                  $return = $this->db->query( $sql);                  $resql = $this->db->query( $sql);
699    
700            if ($resql)
701            {
702                $this->use_webcal=($conf->global->PHPWEBCALENDAR_BILLSTATUS=='always'?1:0);
703        
704                // Appel des triggers
705                include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
706                $interface=new Interfaces($this->db);
707                $result=$interface->run_triggers('BILL_PAYED',$this,$user,$lang,$conf);
708                // Fin appel triggers
709            }
710          }          }
711            
712          /**          /**
713          *    \brief     Tag la facture comme payée complètement          *    \brief     Tag la facture comme non payée complètement
714          *    \param     rowid       id de la facture à modifier          *    \param     rowid       id de la facture à modifier
715          */          */
716          function set_unpayed($rowid)          function set_unpayed($rowid)
717          {          {
718                  $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture set paye=0 WHERE rowid = '.$rowid ;                  $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture set paye=0 WHERE rowid = '.$rowid ;
719                  $return = $this->db->query( $sql);                  $resql = $this->db->query( $sql);
720          }          }
721          /**          /**
722          *    \brief     Tag la facture comme paiement commencée          *    \brief     Tag la facture comme payer partiellement
723          *    \param     rowid       id de la facture à modifier          *    \param     rowid       id de la facture à modifier
724          */          */
725          function set_paiement_started($rowid)          function set_paiement_started($rowid)
# Line 718  class Facture Line 729  class Facture
729          }          }
730    
731          /**          /**
732          *    \brief     Tag la facture comme abandonnée          *    \brief     Tag la facture comme abandonnée + appel trigger BILL_CANCEL
733          *    \param     rowid       id de la facture à modifier          *    \param     rowid       id de la facture à modifier
734          */          */
735          function set_canceled($rowid)          function set_canceled($rowid)
736          {          {
737                  $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture set fk_statut=3 WHERE rowid = '.$rowid;                  $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture set fk_statut=3 WHERE rowid = '.$rowid;
738                  $return = $this->db->query( $sql);                  $resql = $this->db->query( $sql);
739    
740            if ($resql)
741            {
742                $this->use_webcal=($conf->global->PHPWEBCALENDAR_BILLSTATUS=='always'?1:0);
743    
744                // Appel des triggers
745                include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
746                $interface=new Interfaces($this->db);
747                $result=$interface->run_triggers('BILL_CANCEL',$this,$user,$lang,$conf);
748                // Fin appel triggers
749            }
750          }          }
751    
752          /**          /**
753           *      \brief     Tag la facture comme validée et valide la facture           *      \brief     Tag la facture comme validée + appel trigger BILL_VALIDATE
754           *      \param     rowid        id de la facture à valider           *      \param     rowid        id de la facture à valider
755           *      \param     user         utilisateur qui valide la facture           *      \param     user         utilisateur qui valide la facture
756           *      \param     soc          societe           *      \param     soc          societe
# Line 753  class Facture Line 775  class Facture
775              $this->db->begin();              $this->db->begin();
776                            
777                          /*                          /*
778                          * Lecture de la remise exceptionnelle                           * Affectation de la remise exceptionnelle
779                          *                           *
780                          */                           * \todo    Appliquer la remise avoir dans les lignes quand brouillon plutot
781                             *          qu'au moment de la validation
782                             */
783                          $sql  = 'SELECT rowid, rc.amount_ht, fk_soc, fk_user';                          $sql  = 'SELECT rowid, rc.amount_ht, fk_soc, fk_user';
784                          $sql .= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc';                          $sql .= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc';
785                          $sql .= ' WHERE rc.fk_soc ='. $this->socidp;                          $sql .= ' WHERE rc.fk_soc ='. $this->socidp;
# Line 776  class Facture Line 800  class Facture
800                                  dolibarr_syslog('Facture::Valide Erreur lecture Remise');                                  dolibarr_syslog('Facture::Valide Erreur lecture Remise');
801                                  $error++;                                  $error++;
802                          }                          }
   
                         /* Affectation de la remise exceptionnelle */  
803                          if ( $this->_affect_remise_exceptionnelle() <> 0)                          if ( $this->_affect_remise_exceptionnelle() <> 0)
804                          {                          {
805                                  $error++;                                  $error++;
# Line 792  class Facture Line 814  class Facture
814                          $sql .= " SET facnumber='$numfa', fk_statut = 1, fk_user_valid = $user->id";                          $sql .= " SET facnumber='$numfa', fk_statut = 1, fk_user_valid = $user->id";
815    
816                          /* Si l'option est activée on force la date de facture */                          /* Si l'option est activée on force la date de facture */
817                          if (defined('FAC_FORCE_DATE_VALIDATION') && FAC_FORCE_DATE_VALIDATION == '1')                          if ($conf->global->FAC_FORCE_DATE_VALIDATION)
818                          {                          {
819                                  $this->date=time();                                  $this->date=time();
820                                  $datelim=$this->calculate_date_lim_reglement();                                  $datelim=$this->calculate_date_lim_reglement();
# Line 809  class Facture Line 831  class Facture
831              }              }
832                                    
833              /*              /*
834               * Update Stats               * Pour chaque produit, on met a jour indicateur nbvente
835                 * On crée ici une dénormalisation des données pas forcément utilisée.
836               */               */
837                          $sql = 'SELECT fk_product FROM '.MAIN_DB_PREFIX.'facturedet WHERE fk_facture = '.$this->id;                          $sql = 'SELECT fk_product FROM '.MAIN_DB_PREFIX.'facturedet WHERE fk_facture = '.$this->id;
838                          $sql .= ' AND fk_product > 0';                          $sql .= ' AND fk_product > 0';
# Line 834  class Facture Line 857  class Facture
857    
858              if ($error == 0)              if ($error == 0)
859              {              {
860                    $this->use_webcal=($conf->global->PHPWEBCALENDAR_BILLSTATUS=='always'?1:0);
861    
862                  // Appel des triggers                  // Appel des triggers
863                  include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");                  include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
864                  $interface=new Interfaces($this->db);                  $interface=new Interfaces($this->db);
865                  $interface->run_triggers('BILL_VALIDATE',$this,$user,$lang,$conf);                  $result=$interface->run_triggers('BILL_VALIDATE',$this,$user,$lang,$conf);
866                  // Fin appel triggers                  // Fin appel triggers
867    
868                  $this->db->commit();                  $this->db->commit();
# Line 846  class Facture Line 871  class Facture
871                   * Notify                   * Notify
872                   */                   */
873                  $facref = sanitize_string($this->ref);                  $facref = sanitize_string($this->ref);
874                                  $filepdf = FAC_OUTPUTDIR . '/' . $facref . '/' . $facref . '.pdf';                                  $filepdf = $conf->facture->dir_output . '/' . $facref . '/' . $facref . '.pdf';
   
875                                  $mesg = 'La facture '.$this->ref." a été validée.\n";                                  $mesg = 'La facture '.$this->ref." a été validée.\n";
876    
877                  $notify = New Notify($this->db);                  $notify = New Notify($this->db);

Legend:
Removed from v.1.122  
changed lines
  Added in v.1.123

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26