From 0fe708a5f69e3bb47dc6371e98090c4c40945754 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 12 Apr 2010 00:30:52 +0000 Subject: [PATCH] Fix: Error when using iphone Fix: Error in not found class --- htdocs/compta/facture/facture.class.php | 236 ++++++++++++------------ htdocs/fourn/facture/fiche.php | 2 + htdocs/fourn/facture/paiement.php | 2 + htdocs/fourn/paiement/fiche.php | 6 +- htdocs/lib/security.lib.php | 35 ++-- 5 files changed, 145 insertions(+), 136 deletions(-) diff --git a/htdocs/compta/facture/facture.class.php b/htdocs/compta/facture/facture.class.php index a35e30f24e6..9bb3ef585b3 100644 --- a/htdocs/compta/facture/facture.class.php +++ b/htdocs/compta/facture/facture.class.php @@ -1373,103 +1373,110 @@ class Facture extends CommonObject $num = $this->ref; } - $this->update_price(); - - // Validate - $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture'; - $sql.= " SET facnumber='".$num."', fk_statut = 1, fk_user_valid = ".$user->id; - if ($conf->global->FAC_FORCE_DATE_VALIDATION) // If option enabled, we force invoice date + if ($num) { - $sql.= ', datef='.$this->db->idate($this->date); - $sql.= ', date_lim_reglement='.$this->db->idate($this->date_lim_reglement); + $this->update_price(); + + // Validate + $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture'; + $sql.= " SET facnumber='".$num."', fk_statut = 1, fk_user_valid = ".$user->id; + if ($conf->global->FAC_FORCE_DATE_VALIDATION) // If option enabled, we force invoice date + { + $sql.= ', datef='.$this->db->idate($this->date); + $sql.= ', date_lim_reglement='.$this->db->idate($this->date_lim_reglement); + } + $sql.= ' WHERE rowid = '.$this->id; + + dol_syslog("Facture::set_valid sql=".$sql); + $resql=$this->db->query($sql); + if (! $resql) + { + dol_syslog("Facture::set_valid Echec update - 10 - sql=".$sql, LOG_ERR); + dol_print_error($this->db); + $error++; + } + + // On verifie si la facture etait une provisoire + if (! $error && (preg_match('/^[\(]?PROV/i', $this->ref))) + { + // La verif qu'une remise n'est pas utilisee 2 fois est faite au moment de l'insertion de ligne + } + + if (! $error) + { + // Define third party as a customer + $result=$this->client->set_as_client(); + + // Si active on decremente le produit principal et ses composants a la validation de facture + if ($result >= 0 && $conf->stock->enabled && $conf->global->STOCK_CALCULATE_ON_BILL) + { + require_once(DOL_DOCUMENT_ROOT."/product/stock/mouvementstock.class.php"); + + // Loop on each line + for ($i = 0 ; $i < sizeof($this->lignes) ; $i++) + { + if ($this->lignes[$i]->fk_product > 0 && $this->lignes[$i]->product_type == 0) + { + $mouvP = new MouvementStock($this->db); + // We decrease stock for product + $entrepot_id = "1"; // TODO ajouter possibilite de choisir l'entrepot + $result=$mouvP->livraison($user, $this->lignes[$i]->fk_product, $entrepot_id, $this->lignes[$i]->qty, $this->lignes[$i]->subprice); + if ($result < 0) { $error++; } + } + } + } + } + + if (! $error) + { + // Rename directory if dir was a temporary ref + if (preg_match('/^[\(]?PROV/i', $this->ref)) + { + // On renomme repertoire facture ($this->ref = ancienne ref, $num = nouvelle ref) + // afin de ne pas perdre les fichiers attaches + $facref = dol_sanitizeFileName($this->ref); + $snumfa = dol_sanitizeFileName($num); + $dirsource = $conf->facture->dir_output.'/'.$facref; + $dirdest = $conf->facture->dir_output.'/'.$snumfa; + if (file_exists($dirsource)) + { + dol_syslog("Facture::set_valid rename dir ".$dirsource." into ".$dirdest); + + if (@rename($dirsource, $dirdest)) + { + dol_syslog("Rename ok"); + // Suppression ancien fichier PDF dans nouveau rep + dol_delete_file($conf->facture->dir_output.'/'.$snumfa.'/'.$facref.'.*'); + } + } + } + } + + // Set new ref + if (! $error) + { + $this->ref = $num; + $this->facnumber=$num; + } + + $this->use_webcal=($conf->global->PHPWEBCALENDAR_BILLSTATUS=='always'?1:0); + + // Trigger calls + if (! $error) + { + // Appel des triggers + include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php"); + $interface=new Interfaces($this->db); + $result=$interface->run_triggers('BILL_VALIDATE',$this,$user,$langs,$conf); + if ($result < 0) { $error++; $this->errors=$interface->errors; } + // Fin appel triggers + } } - $sql.= ' WHERE rowid = '.$this->id; - - dol_syslog("Facture::set_valid sql=".$sql); - $resql=$this->db->query($sql); - if (! $resql) + else { - dol_syslog("Facture::set_valid Echec update - 10 - sql=".$sql, LOG_ERR); - dol_print_error($this->db); $error++; } - // On verifie si la facture etait une provisoire - if (! $error && (preg_match('/^[\(]?PROV/i', $this->ref))) - { - // La verif qu'une remise n'est pas utilisee 2 fois est faite au moment de l'insertion de ligne - } - - if (! $error) - { - // Define third party as a customer - $result=$this->client->set_as_client(); - - // Si active on decremente le produit principal et ses composants a la validation de facture - if ($result >= 0 && $conf->stock->enabled && $conf->global->STOCK_CALCULATE_ON_BILL) - { - require_once(DOL_DOCUMENT_ROOT."/product/stock/mouvementstock.class.php"); - - // Loop on each line - for ($i = 0 ; $i < sizeof($this->lignes) ; $i++) - { - if ($this->lignes[$i]->fk_product > 0 && $this->lignes[$i]->product_type == 0) - { - $mouvP = new MouvementStock($this->db); - // We decrease stock for product - $entrepot_id = "1"; // TODO ajouter possibilite de choisir l'entrepot - $result=$mouvP->livraison($user, $this->lignes[$i]->fk_product, $entrepot_id, $this->lignes[$i]->qty, $this->lignes[$i]->subprice); - if ($result < 0) { $error++; } - } - } - } - } - - if (! $error) - { - // Rename directory if dir was a temporary ref - if (preg_match('/^[\(]?PROV/i', $this->ref)) - { - // On renomme repertoire facture ($this->ref = ancienne ref, $num = nouvelle ref) - // afin de ne pas perdre les fichiers attaches - $facref = dol_sanitizeFileName($this->ref); - $snumfa = dol_sanitizeFileName($num); - $dirsource = $conf->facture->dir_output.'/'.$facref; - $dirdest = $conf->facture->dir_output.'/'.$snumfa; - if (file_exists($dirsource)) - { - dol_syslog("Facture::set_valid rename dir ".$dirsource." into ".$dirdest); - - if (@rename($dirsource, $dirdest)) - { - dol_syslog("Rename ok"); - // Suppression ancien fichier PDF dans nouveau rep - dol_delete_file($conf->facture->dir_output.'/'.$snumfa.'/'.$facref.'.*'); - } - } - } - } - - // Set new ref - if (! $error) - { - $this->ref = $num; - $this->facnumber=$num; - } - - $this->use_webcal=($conf->global->PHPWEBCALENDAR_BILLSTATUS=='always'?1:0); - - // Trigger calls - if (! $error) - { - // Appel des triggers - include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php"); - $interface=new Interfaces($this->db); - $result=$interface->run_triggers('BILL_VALIDATE',$this,$user,$langs,$conf); - if ($result < 0) { $error++; $this->errors=$interface->errors; } - // Fin appel triggers - } - if (! $error) { $this->db->commit(); @@ -2219,39 +2226,36 @@ class Facture extends CommonObject global $conf, $db, $langs; $langs->load("bills"); - if (! empty($conf->global->FACTURE_ADDON)) + if (empty($conf->global->FACTURE_ADDON)) { - $file = $conf->global->FACTURE_ADDON."/".$conf->global->FACTURE_ADDON.".modules.php"; - $classname = "mod_facture_".$conf->global->FACTURE_ADDON; + $conf->global->FACTURE_ADDON='terre'; + } - // Include file with class - $mybool=false; - foreach ($conf->file->dol_document_root as $dirroot) - { - $dir = $dirroot."/includes/modules/facture/"; - // Load file with numbering class (if found) - $mybool|=@include_once($dir.$file); - } - if (! $mybool) dol_print_error('',"Failed to include file ".$file); + $file = $conf->global->FACTURE_ADDON."/".$conf->global->FACTURE_ADDON.".modules.php"; + $classname = "mod_facture_".$conf->global->FACTURE_ADDON; - $obj = new $classname(); + // Include file with class + $mybool=false; + foreach ($conf->file->dol_document_root as $dirroot) + { + $dir = $dirroot."/includes/modules/facture/"; + // Load file with numbering class (if found) + $mybool|=@include_once($dir.$file); + } + if (! $mybool) dol_print_error('',"Failed to include file ".$file); - $numref = ""; - $numref = $obj->getNumRef($soc,$this); + $obj = new $classname(); - if ( $numref != "") - { - return $numref; - } - else - { - dol_print_error($db,"Facture::getNextNumRef ".$obj->error); - return ""; - } + $numref = ""; + $numref = $obj->getNumRef($soc,$this); + + if ( $numref != "") + { + return $numref; } else { - print $langs->trans("Error")." ".$langs->trans("Error_FACTURE_ADDON_NotDefined"); + dol_print_error($db,"Facture::getNextNumRef ".$obj->error); return ""; } } diff --git a/htdocs/fourn/facture/fiche.php b/htdocs/fourn/facture/fiche.php index a3439f92bf5..142e499ff13 100644 --- a/htdocs/fourn/facture/fiche.php +++ b/htdocs/fourn/facture/fiche.php @@ -29,6 +29,8 @@ require("../../main.inc.php"); require_once(DOL_DOCUMENT_ROOT."/html.formfile.class.php"); +require_once(DOL_DOCUMENT_ROOT.'/fourn/fournisseur.class.php'); +require_once(DOL_DOCUMENT_ROOT.'/fourn/fournisseur.facture.class.php'); require_once(DOL_DOCUMENT_ROOT.'/fourn/facture/paiementfourn.class.php'); require_once(DOL_DOCUMENT_ROOT.'/lib/fourn.lib.php'); require_once(DOL_DOCUMENT_ROOT.'/product/product.class.php'); diff --git a/htdocs/fourn/facture/paiement.php b/htdocs/fourn/facture/paiement.php index d0c0dd6253b..32aa8d10385 100644 --- a/htdocs/fourn/facture/paiement.php +++ b/htdocs/fourn/facture/paiement.php @@ -28,6 +28,8 @@ */ require("../../main.inc.php"); +require(DOL_DOCUMENT_ROOT.'/fourn/fournisseur.class.php'); +require(DOL_DOCUMENT_ROOT.'/fourn/fournisseur.facture.class.php'); require(DOL_DOCUMENT_ROOT.'/fourn/facture/paiementfourn.class.php'); $langs->load('companies'); diff --git a/htdocs/fourn/paiement/fiche.php b/htdocs/fourn/paiement/fiche.php index 88910281642..66d54b0b6f6 100644 --- a/htdocs/fourn/paiement/fiche.php +++ b/htdocs/fourn/paiement/fiche.php @@ -21,15 +21,15 @@ /** * \file htdocs/fourn/paiement/fiche.php * \ingroup facture, fournisseur - * \brief Onglet paiement d'un paiement fournisseur + * \brief Tab to show a payment of a supplier invoice * \remarks Fichier presque identique a compta/paiement/fiche.php * \version $Id$ */ - require("../../main.inc.php"); require(DOL_DOCUMENT_ROOT.'/fourn/facture/paiementfourn.class.php'); - +require(DOL_DOCUMENT_ROOT.'/fourn/fournisseur.class.php'); +require(DOL_DOCUMENT_ROOT.'/fourn/fournisseur.facture.class.php'); $langs->load('bills'); $langs->load('banks'); diff --git a/htdocs/lib/security.lib.php b/htdocs/lib/security.lib.php index 0deacb10c8d..2045a8b805d 100644 --- a/htdocs/lib/security.lib.php +++ b/htdocs/lib/security.lib.php @@ -49,31 +49,32 @@ function dol_loginfunction($langs,$conf,$mysoc) $php_self.= $_SERVER["QUERY_STRING"]?'?'.$_SERVER["QUERY_STRING"]:''; // Select templates - if ($conf->browser->phone) + $template_dir=DOL_DOCUMENT_ROOT.'/core/tpl/'; // Common case + if (! empty($conf->global->MAIN_USE_THEME_TEMPLATES)) // Disabled by default because make useless filsesystem calls that reduce speed. { - if (file_exists(DOL_DOCUMENT_ROOT."/theme/phones/".$conf->browser->phone)) + if ($conf->browser->phone && ! empty($conf->global->MAIN_SMARTY)) { - $template_dir=DOL_DOCUMENT_ROOT."/theme/phones/".$conf->browser->phone."/tpl/"; + // Special cases + if (file_exists(DOL_DOCUMENT_ROOT."/theme/phones/".$conf->browser->phone)) + { + $template_dir=DOL_DOCUMENT_ROOT."/theme/phones/".$conf->browser->phone."/tpl/"; + } + else + { + $template_dir=DOL_DOCUMENT_ROOT."/theme/phones/others/tpl/"; + } } else { - $template_dir=DOL_DOCUMENT_ROOT."/theme/phones/others/tpl/"; + if ((! empty($conf->global->MAIN_SMARTY) && file_exists(DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/tpl/login.tpl")) + || (empty($conf->global->MAIN_SMARTY) && file_exists(DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/tpl/login.tpl.php"))) + { + $template_dir=DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/tpl/"; + } } } - else - { - if (file_exists(DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/tpl/login.tpl") - || file_exists(DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/tpl/login.tpl.php")) - { - $template_dir=DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/tpl/"; - } - else - { - $template_dir=DOL_DOCUMENT_ROOT.'/core/tpl/'; - } - $conf->css = "/theme/".$conf->theme."/".$conf->theme.".css.php?lang=".$langs->defaultlang; - } + $conf->css = "/theme/".$conf->theme."/".$conf->theme.".css.php?lang=".$langs->defaultlang; // Set cookie for timeout management $sessiontimeout='DOLSESSTIMEOUT_'.md5($_SERVER["SERVER_NAME"].$_SERVER["DOCUMENT_ROOT"]);