コード例 #1
0
 /**
  * Update thirdparty
  *
  * @param int   $id             Id of thirdparty to update
  * @param array $request_data   Datas   
  * @return int 
  * 
  * @url	PUT thirdparty/{id}
  */
 function put($id, $request_data = NULL)
 {
     if (!DolibarrApiAccess::$user->rights->societe->creer) {
         throw new RestException(401);
     }
     $result = $this->company->fetch($id);
     if (!$result) {
         throw new RestException(404, 'Thirdparty not found');
     }
     if (!DolibarrApi::_checkAccessToResource('societe', $this->company->id)) {
         throw new RestException(401, 'Access not allowed for login ' . DolibarrApiAccess::$user->login);
     }
     foreach ($request_data as $field => $value) {
         $this->company->{$field} = $value;
     }
     if ($this->company->update($id, DolibarrApiAccess::$user, 1, '', '', 'update')) {
         return $this->get($id);
     }
     return false;
 }
コード例 #2
0
ファイル: fiche.php プロジェクト: netors/dolibarr
$pageprev = $page - 1;
$pagenext = $page + 1;
if (!$sortorder) {
    $sortorder = "ASC";
}
if (!$sortfield) {
    $sortfield = "nom";
}
/*
 * Actions
 */
if ($_POST['action'] == 'setcustomeraccountancycode') {
    $societe = new Societe($db);
    $result = $societe->fetch($_POST['socid']);
    $societe->code_compta = $_POST["customeraccountancycode"];
    $result = $societe->update($societe->id, $user, 1, 1, 0);
    if ($result < 0) {
        $mesg = join(',', $societe->errors);
    }
    $POST["action"] = "";
    $socid = $_POST["socid"];
}
if ($_GET["action"] == 'attribute_prefix' && $user->rights->societe->creer) {
    $societe = new Societe($db, $_GET["socid"]);
    $societe->attribute_prefix($db, $_GET["socid"]);
}
// conditions de reglement
if ($_POST["action"] == 'setconditions' && $user->rights->societe->creer) {
    $societe = new Societe($db, $_GET["socid"]);
    $societe->cond_reglement = $_POST['cond_reglement_id'];
    $sql = "UPDATE " . MAIN_DB_PREFIX . "societe SET cond_reglement='" . $_POST['cond_reglement_id'];
コード例 #3
0
/**
 * Update a thirdparty
 *
 * @param	array		$authentication		Array of authentication information
 * @param	Societe		$thirdparty		    Thirdparty
 * @return	array							Array result
 */
function updateThirdParty($authentication, $thirdparty)
{
    global $db, $conf, $langs;
    $now = dol_now();
    dol_syslog("Function: updateThirdParty login="******"Thirdparty id is mandatory.";
    }
    if (!$error) {
        $objectfound = false;
        include_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php';
        $object = new Societe($db);
        $result = $object->fetch($thirdparty['id']);
        if (!empty($object->id)) {
            $objectfound = true;
            $object->ref = $thirdparty['ref'];
            $object->name = $thirdparty['ref'];
            $object->ref_ext = $thirdparty['ref_ext'];
            $object->status = $thirdparty['status'];
            $object->client = $thirdparty['client'];
            $object->fournisseur = $thirdparty['supplier'];
            $object->code_client = $thirdparty['customer_code'];
            $object->code_fournisseur = $thirdparty['supplier_code'];
            $object->code_compta = $thirdparty['customer_code_accountancy'];
            $object->code_compta_fournisseur = $thirdparty['supplier_code_accountancy'];
            $object->date_creation = $now;
            $object->note_private = $thirdparty['note_private'];
            $object->note_public = $thirdparty['note_public'];
            $object->address = $thirdparty['address'];
            $object->zip = $thirdparty['zip'];
            $object->town = $thirdparty['town'];
            $object->country_id = $thirdparty['country_id'];
            if ($thirdparty['country_code']) {
                $object->country_id = getCountry($thirdparty['country_code'], 3);
            }
            $object->province_id = $thirdparty['province_id'];
            //if ($thirdparty['province_code']) $newobject->province_code=getCountry($thirdparty['province_code'],3);
            $object->phone = $thirdparty['phone'];
            $object->fax = $thirdparty['fax'];
            $object->email = $thirdparty['email'];
            $object->url = $thirdparty['url'];
            $object->idprof1 = $thirdparty['profid1'];
            $object->idprof2 = $thirdparty['profid2'];
            $object->idprof3 = $thirdparty['profid3'];
            $object->idprof4 = $thirdparty['profid4'];
            $object->idprof5 = $thirdparty['profid5'];
            $object->idprof6 = $thirdparty['profid6'];
            $object->capital = $thirdparty['capital'];
            $object->barcode = $thirdparty['barcode'];
            $object->tva_assuj = $thirdparty['vat_used'];
            $object->tva_intra = $thirdparty['vat_number'];
            $object->canvas = $thirdparty['canvas'];
            //Retreive all extrafield for thirdsparty
            // fetch optionals attributes and labels
            $extrafields = new ExtraFields($db);
            $extralabels = $extrafields->fetch_name_optionals_label('societe', true);
            foreach ($extrafields->attribute_label as $key => $label) {
                $key = 'options_' . $key;
                $object->array_options[$key] = $thirdparty[$key];
            }
            $db->begin();
            $result = $object->update($thirdparty['id'], $fuser);
            if ($result <= 0) {
                $error++;
            }
        }
        if (!$error && $objectfound) {
            $db->commit();
            $objectresp = array('result' => array('result_code' => 'OK', 'result_label' => ''), 'id' => $object->id);
        } elseif ($objectfound) {
            $db->rollback();
            $error++;
            $errorcode = 'KO';
            $errorlabel = $object->error;
        } else {
            $error++;
            $errorcode = 'NOT_FOUND';
            $errorlabel = 'Thirdparty id=' . $thirdparty['id'] . ' cannot be found';
        }
    }
    if ($error) {
        $objectresp = array('result' => array('result_code' => $errorcode, 'result_label' => $errorlabel));
    }
    return $objectresp;
}
コード例 #4
0
 /**
  *	Update a member in database (standard information and password)
  *
  *	@param	User	$user				User making update
  *	@param	int		$notrigger			1=disable trigger UPDATE (when called by create)
  *	@param	int		$nosyncuser			0=Synchronize linked user (standard info), 1=Do not synchronize linked user
  *	@param	int		$nosyncuserpass		0=Synchronize linked user (password), 1=Do not synchronize linked user
  *	@param	int		$nosyncthirdparty	0=Synchronize linked thirdparty (standard info), 1=Do not synchronize linked thirdparty
  * 	@param	string	$action				Current action for hookmanager
  * 	@return	int							<0 if KO, >0 if OK
  */
 function update($user, $notrigger = 0, $nosyncuser = 0, $nosyncuserpass = 0, $nosyncthirdparty = 0, $action = 'update')
 {
     global $conf, $langs, $hookmanager;
     $nbrowsaffected = 0;
     $error = 0;
     dol_syslog(get_class($this) . "::update notrigger=" . $notrigger . ", nosyncuser="******", nosyncuserpass="******" nosyncthirdparty=" . $nosyncthirdparty . ", email=" . $this->email);
     // Clean parameters
     $this->lastname = trim($this->lastname) ? trim($this->lastname) : trim($this->lastname);
     $this->firstname = trim($this->firstname) ? trim($this->firstname) : trim($this->firstname);
     $this->address = $this->address ? $this->address : $this->address;
     $this->zip = $this->zip ? $this->zip : $this->zip;
     $this->town = $this->town ? $this->town : $this->town;
     $this->country_id = $this->country_id > 0 ? $this->country_id : $this->country_id;
     $this->state_id = $this->state_id > 0 ? $this->state_id : $this->state_id;
     if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) {
         $this->lastname = ucwords(trim($this->lastname));
     }
     if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) {
         $this->firstname = ucwords(trim($this->firstname));
     }
     // Check parameters
     if (!empty($conf->global->ADHERENT_MAIL_REQUIRED) && !isValidEMail($this->email)) {
         $langs->load("errors");
         $this->error = $langs->trans("ErrorBadEMail", $this->email);
         return -1;
     }
     $this->db->begin();
     $sql = "UPDATE " . MAIN_DB_PREFIX . "adherent SET";
     $sql .= " civility = " . (!is_null($this->civility_id) ? "'" . $this->civility_id . "'" : "null");
     $sql .= ", firstname = " . ($this->firstname ? "'" . $this->db->escape($this->firstname) . "'" : "null");
     $sql .= ", lastname=" . ($this->lastname ? "'" . $this->db->escape($this->lastname) . "'" : "null");
     $sql .= ", login="******"'" . $this->db->escape($this->login) . "'" : "null");
     $sql .= ", societe=" . ($this->societe ? "'" . $this->db->escape($this->societe) . "'" : "null");
     $sql .= ", fk_soc=" . ($this->fk_soc > 0 ? "'" . $this->fk_soc . "'" : "null");
     $sql .= ", address=" . ($this->address ? "'" . $this->db->escape($this->address) . "'" : "null");
     $sql .= ", zip=" . ($this->zip ? "'" . $this->db->escape($this->zip) . "'" : "null");
     $sql .= ", town=" . ($this->town ? "'" . $this->db->escape($this->town) . "'" : "null");
     $sql .= ", country=" . ($this->country_id > 0 ? "'" . $this->country_id . "'" : "null");
     $sql .= ", state_id=" . ($this->state_id > 0 ? "'" . $this->state_id . "'" : "null");
     $sql .= ", email='" . $this->email . "'";
     $sql .= ", skype='" . $this->skype . "'";
     $sql .= ", phone=" . ($this->phone ? "'" . $this->db->escape($this->phone) . "'" : "null");
     $sql .= ", phone_perso=" . ($this->phone_perso ? "'" . $this->db->escape($this->phone_perso) . "'" : "null");
     $sql .= ", phone_mobile=" . ($this->phone_mobile ? "'" . $this->db->escape($this->phone_mobile) . "'" : "null");
     $sql .= ", note_private=" . ($this->note_private ? "'" . $this->db->escape($this->note_private) . "'" : "null");
     $sql .= ", note_public=" . ($this->note_private ? "'" . $this->db->escape($this->note_public) . "'" : "null");
     $sql .= ", photo=" . ($this->photo ? "'" . $this->photo . "'" : "null");
     $sql .= ", public='" . $this->public . "'";
     $sql .= ", statut=" . $this->statut;
     $sql .= ", fk_adherent_type=" . $this->typeid;
     $sql .= ", morphy='" . $this->morphy . "'";
     $sql .= ", birth=" . ($this->birth ? "'" . $this->db->idate($this->birth) . "'" : "null");
     if ($this->datefin) {
         $sql .= ", datefin='" . $this->db->idate($this->datefin) . "'";
     }
     // Ne doit etre modifie que par effacement cotisation
     if ($this->datevalid) {
         $sql .= ", datevalid='" . $this->db->idate($this->datevalid) . "'";
     }
     // Ne doit etre modifie que par validation adherent
     $sql .= ", fk_user_mod=" . ($user->id > 0 ? $user->id : 'null');
     // Can be null because member can be create by a guest
     $sql .= " WHERE rowid = " . $this->id;
     dol_syslog(get_class($this) . "::update update member", LOG_DEBUG);
     $resql = $this->db->query($sql);
     if ($resql) {
         unset($this->country_code);
         unset($this->country);
         unset($this->state_code);
         unset($this->state);
         $nbrowsaffected += $this->db->affected_rows($resql);
         $action = 'update';
         // Actions on extra fields (by external module)
         // TODO le hook fait double emploi avec le trigger !!
         $hookmanager->initHooks(array('memberdao'));
         $parameters = array('id' => $this->id);
         $action = '';
         $reshook = $hookmanager->executeHooks('insertExtraFields', $parameters, $this, $action);
         // Note that $action and $object may have been modified by some hooks
         if (empty($reshook)) {
             if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) {
                 $result = $this->insertExtraFields();
                 if ($result < 0) {
                     $error++;
                 }
             }
         } else {
             if ($reshook < 0) {
                 $error++;
             }
         }
         // Update password
         if (!$error && $this->pass) {
             dol_syslog(get_class($this) . "::update update password");
             if ($this->pass != $this->pass_indatabase && $this->pass != $this->pass_indatabase_crypted) {
                 // Si mot de passe saisi et different de celui en base
                 $result = $this->setPassword($user, $this->pass, 0, $notrigger, $nosyncuserpass);
                 if (!$nbrowsaffected) {
                     $nbrowsaffected++;
                 }
             }
         }
         // Remove links to user and replace with new one
         if (!$error) {
             dol_syslog(get_class($this) . "::update update link to user");
             $sql = "UPDATE " . MAIN_DB_PREFIX . "user SET fk_member = NULL WHERE fk_member = " . $this->id;
             dol_syslog(get_class($this) . "::update", LOG_DEBUG);
             $resql = $this->db->query($sql);
             if (!$resql) {
                 $this->error = $this->db->error();
                 $this->db->rollback();
                 return -5;
             }
             // If there is a user linked to this member
             if ($this->user_id > 0) {
                 $sql = "UPDATE " . MAIN_DB_PREFIX . "user SET fk_member = " . $this->id . " WHERE rowid = " . $this->user_id;
                 dol_syslog(get_class($this) . "::update", LOG_DEBUG);
                 $resql = $this->db->query($sql);
                 if (!$resql) {
                     $this->error = $this->db->error();
                     $this->db->rollback();
                     return -5;
                 }
             }
         }
         if (!$error && $nbrowsaffected) {
             // Update information on linked user if it is an update
             if ($this->user_id > 0 && !$nosyncuser) {
                 require_once DOL_DOCUMENT_ROOT . '/user/class/user.class.php';
                 dol_syslog(get_class($this) . "::update update linked user");
                 $luser = new User($this->db);
                 $result = $luser->fetch($this->user_id);
                 if ($result >= 0) {
                     //var_dump($this->user_login);exit;
                     //var_dump($this->login);exit;
                     $luser->login = $this->login;
                     $luser->civility_id = $this->civility_id;
                     $luser->firstname = $this->firstname;
                     $luser->lastname = $this->lastname;
                     $luser->pass = $this->pass;
                     $luser->societe_id = $this->societe;
                     $luser->email = $this->email;
                     $luser->skype = $this->skype;
                     $luser->office_phone = $this->phone;
                     $luser->user_mobile = $this->phone_mobile;
                     $luser->fk_member = $this->id;
                     $result = $luser->update($user, 0, 1, 1);
                     // Use nosync to 1 to avoid cyclic updates
                     if ($result < 0) {
                         $this->error = $luser->error;
                         dol_syslog(get_class($this) . "::update " . $this->error, LOG_ERR);
                         $error++;
                     }
                 } else {
                     $this->error = $luser->error;
                     $error++;
                 }
             }
             // Update information on linked thirdparty if it is an update
             if ($this->fk_soc > 0 && !$nosyncthirdparty) {
                 require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php';
                 dol_syslog(get_class($this) . "::update update linked thirdparty");
                 // This member is linked with a thirdparty, so we also update thirdparty informations
                 // if this is an update.
                 $lthirdparty = new Societe($this->db);
                 $result = $lthirdparty->fetch($this->fk_soc);
                 if ($result >= 0) {
                     $lthirdparty->address = $this->address;
                     $lthirdparty->zip = $this->zip;
                     $lthirdparty->town = $this->town;
                     $lthirdparty->email = $this->email;
                     $lthirdparty->skype = $this->skype;
                     $lthirdparty->phone = $this->phone;
                     $lthirdparty->state_id = $this->state_id;
                     $lthirdparty->country_id = $this->country_id;
                     $lthirdparty->country_id = $this->country_id;
                     //$lthirdparty->phone_mobile=$this->phone_mobile;
                     $result = $lthirdparty->update($this->fk_soc, $user, 0, 1, 1, 'update');
                     // Use sync to 0 to avoid cyclic updates
                     if ($result < 0) {
                         $this->error = $lthirdparty->error;
                         dol_syslog(get_class($this) . "::update " . $this->error, LOG_ERR);
                         $error++;
                     }
                 } else {
                     $this->error = $lthirdparty->error;
                     $error++;
                 }
             }
             if (!$error && !$notrigger) {
                 // Call trigger
                 $result = $this->call_trigger('MEMBER_MODIFY', $user);
                 if ($result < 0) {
                     $error++;
                 }
                 // End call triggers
             }
         }
         if (!$error) {
             $this->db->commit();
             return $nbrowsaffected;
         } else {
             $this->db->rollback();
             return -1;
         }
     } else {
         $this->db->rollback();
         $this->error = $this->db->lasterror();
         return -2;
     }
 }
コード例 #5
0
ファイル: fiche.php プロジェクト: nrjacker4/crm-php
$pageprev = $page - 1;
$pagenext = $page + 1;
if (!$sortorder) {
    $sortorder = "ASC";
}
if (!$sortfield) {
    $sortfield = "nom";
}
$object = new Societe($db);
/*
 * Actions
 */
if ($action == 'setcustomeraccountancycode') {
    $result = $object->fetch($id);
    $object->code_compta = $_POST["customeraccountancycode"];
    $result = $object->update($object->id, $user, 1, 1, 0);
    if ($result < 0) {
        $mesgs[] = join(',', $object->errors);
    }
    $action = "";
}
// conditions de reglement
if ($action == 'setconditions' && $user->rights->societe->creer) {
    $object->fetch($id);
    $result = $object->setPaymentTerms(GETPOST('cond_reglement_id', 'int'));
    if ($result < 0) {
        dol_print_error($db, $object->error);
    }
}
// mode de reglement
if ($action == 'setmode' && $user->rights->societe->creer) {
コード例 #6
0
	/**
     *      Update parameters of third party
     *      @param      id              			id societe
     *      @param      user            			Utilisateur qui demande la mise a jour
     *      @param      call_trigger    			0=non, 1=oui
     *		@param		allowmodcodeclient			Inclut modif code client et code compta
     *		@param		allowmodcodefournisseur		Inclut modif code fournisseur et code compta fournisseur
     *      @return     int             			<0 si ko, >=0 si ok
     */
    function update($id, $user='', $call_trigger=1, $allowmodcodeclient=0, $allowmodcodefournisseur=0)
    {
    	$result = parent::update($id, $user, $call_trigger, $allowmodcodeclient, $allowmodcodefournisseur);

    	return $result;
    }
コード例 #7
0
 function import2Dolibarr($object, $typeimport)
 {
     global $conf;
     global $langs;
     $this->process_msg = '';
     $error = 0;
     $fp = @fopen($this->filename, "r");
     if ($fp) {
         switch ($object) {
             case 'ImportStock':
                 $doliprod = new Product($this->db);
                 $i = 0;
                 while ($ligne = fgetcsv($fp, 1000, ";")) {
                     $doliprod->id = '';
                     $i++;
                     if ($this->firstline && $i == 1) {
                         continue;
                     }
                     if ($conf->global->IMPORT_BARCODE) {
                         $ligne[0] = $this->get_product_by_barcode($ligne[0]);
                     }
                     if ($doliprod->fetch('', $ligne[0]) <= 0) {
                         $this->process_msg .= $langs->trans("ErrProdNoExist", $ligne[0], $doliprod->error) . "\n";
                     } else {
                         $pid = $doliprod->id;
                         $doliprod->ref = $ligne[0];
                         $entrepot = $ligne[1];
                         $newstock = $ligne[2];
                         $price = $ligne[3];
                         if ($conf->global->IMPORT_TOTAL_STOCK) {
                             $doliprod->load_stock();
                             dol_syslog("stock produit " . $doliprod->stock_warehouse[$entrepot]->real . " entrepot " . $entrepot . " " . $doliprod->stock_reel, LOG_DEBUG);
                             // correction de stock
                             $delta = 0;
                             if ($newstock > $doliprod->stock_warehouse[$entrepot]->real) {
                                 $delta = $newstock - $doliprod->stock_warehouse[$entrepot]->real;
                                 $sens = 0;
                             } elseif ($newstock < $doliprod->stock_warehouse[$entrepot]->real) {
                                 $delta = $doliprod->stock_warehouse[$entrepot]->real - $newstock;
                                 $sens = 1;
                             }
                             if ($delta) {
                                 $res = $doliprod->correct_stock($this->user, $entrepot, $delta, $sens, $langs->trans("StockCorrection"), $price);
                                 if ($res < 0) {
                                     $this->process_msg .= $langs->trans("ErrMovStock", $ligne[0], $doliprod->error) . "\n";
                                     $error++;
                                 }
                             }
                             dol_syslog("maj stock delta = " . $delta . " sens " . $sens, LOG_DEBUG);
                         } else {
                             $res = $doliprod->correct_stock($this->user, $entrepot, abs($newstock), $newstock > 0 ? 0 : 1, $langs->trans("StockCorrection"), $price);
                             if ($res < 0) {
                                 $this->process_msg .= $langs->trans("ErrMovStock", $ligne[0], $doliprod->error) . "\n";
                                 $error++;
                             }
                         }
                     }
                 }
                 break;
             case 'ImportProduct':
                 //$doliprod = new Product($this->db);
                 $i = 0;
                 while ($ligne = fgetcsv($fp, 1000, ";")) {
                     $i++;
                     $doliprod = new Product($this->db);
                     $doliprod->id = '';
                     if ($this->firstline && $i == 1) {
                         continue;
                     }
                     if ($doliprod->fetch('', $ligne[0]) < 0) {
                         $this->process_msg .= $langs->trans("ErrProdNoExist", $ligne[0], $doliprod->error) . "\n";
                     } else {
                         $pid = $doliprod->id;
                         $doliprod->ref = $ligne[0];
                         if (!empty($ligne[1])) {
                             $doliprod->libelle = $ligne[1];
                         }
                         if (!empty($ligne[2])) {
                             $doliprod->status = $ligne[2];
                         }
                         $doliprod->status_buy = 1;
                         if (!empty($ligne[3])) {
                             $doliprod->description = $ligne[3];
                         }
                         if (!empty($ligne[4])) {
                             $doliprod->price = $ligne[4];
                         }
                         if (!empty($ligne[5])) {
                             $doliprod->tva_tx = $ligne[5];
                         }
                         if (!empty($ligne[6])) {
                             $doliprod->weight = $ligne[6];
                         }
                         if (!empty($ligne[7])) {
                             $doliprod->volume = $ligne[7];
                         }
                         if (!empty($ligne[9])) {
                             $doliprod->barcode = $ligne[9];
                         }
                         if (!empty($ligne[9])) {
                             $doliprod->barcode_type = dol_getIdFromCode($this->db, $ligne[10], 'c_barcode_type', 'libelle', 'rowid');
                         }
                         if (!empty($ligne[10])) {
                             $doliprod->type = $ligne[11];
                         }
                         $doliprod->price_base_type = 'HT';
                         $this->db->begin;
                         switch ($typeimport) {
                             case 'C':
                                 if ($pid > 0) {
                                     if ($doliprod->update($pid, $this->user) < 0) {
                                         $this->process_msg .= $langs->trans("ErrProductUpdate", $ligne[0], $doliprod->error) . "\n";
                                         $error++;
                                     }
                                     if ($doliprod->updatePrice($doliprod->price, $doliprod->price_base_type, $this->user) < 0) {
                                         $this->process_msg .= $langs->trans("ErrProductUpdate", $ligne[0], $doliprod->error) . "\n";
                                         $error++;
                                     }
                                 } else {
                                     if ($doliprod->create($this->user) < 0) {
                                         $this->process_msg .= $langs->trans("ErrProductCreate", $ligne[0], $doliprod->error) . "\n";
                                         $error++;
                                     } else {
                                         // image et code barre
                                         if ($ligne[8]) {
                                             $this->add_photo_web($conf->produit->dir_output, $ligne[8], $doliprod->id);
                                         }
                                         /*if ($ligne[9]) {
                                         			if ($doliprod->setValueFrom('fk_barcode_type', 2) < 0){
                                         				$this->process_msg .= $langs->trans("ErrProductCreate", $ligne[0], $doliprod->error)."\n"; // TODO paramétrer
                                         				$error++;
                                         			}
                                         			if ($doliprod->setValueFrom('barcode', $ligne[9]) < 0 ){
                                         				$this->process_msg .= $langs->trans("ErrProductCreate", $ligne[0], $doliprod->error)."\n";
                                         				$error++;
                                         			}
                                         		}*/
                                     }
                                 }
                                 break;
                                 /*case 'M':
                                 		if ($pid>0) 
                                 		{
                                 			if ($doliprod->update($pid, $this->user) < 0){
                                 				$this->process_msg .= $langs->trans("ErrProductUpdate", $ligne[0], $doliprod->error)."\n";
                                 				$error++;
                                 			}
                                 			if (version_compare(DOL_VERSION, 3.5) >= 0){
                                 				if ($doliprod->updatePrice($doliprod->price, $doliprod->price_base_type, $this->user) < 0){
                                 					$this->process_msg .= $langs->trans("ErrProductUpdate", $ligne[0], $doliprod->error)."\n";
                                 					$error++;
                                 				}
                                 			}
                                 			else{
                                 				if ($doliprod->updatePrice($doliprod->id, $doliprod->price, $doliprod->price_base_type, $this->user) < 0){
                                 					$this->process_msg .= $langs->trans("ErrProductUpdate", $ligne[0], $doliprod->error)."\n";
                                 					$error++;
                                 				}
                                 			}
                                 		}
                                 		else $this->process_msg .= $langs->trans("Untreated", $i).' '.$langs->trans("ErrProdNoExist", $ligne[0])."\n";
                                 		break;*/
                             /*case 'M':
                             		if ($pid>0) 
                             		{
                             			if ($doliprod->update($pid, $this->user) < 0){
                             				$this->process_msg .= $langs->trans("ErrProductUpdate", $ligne[0], $doliprod->error)."\n";
                             				$error++;
                             			}
                             			if (version_compare(DOL_VERSION, 3.5) >= 0){
                             				if ($doliprod->updatePrice($doliprod->price, $doliprod->price_base_type, $this->user) < 0){
                             					$this->process_msg .= $langs->trans("ErrProductUpdate", $ligne[0], $doliprod->error)."\n";
                             					$error++;
                             				}
                             			}
                             			else{
                             				if ($doliprod->updatePrice($doliprod->id, $doliprod->price, $doliprod->price_base_type, $this->user) < 0){
                             					$this->process_msg .= $langs->trans("ErrProductUpdate", $ligne[0], $doliprod->error)."\n";
                             					$error++;
                             				}
                             			}
                             		}
                             		else $this->process_msg .= $langs->trans("Untreated", $i).' '.$langs->trans("ErrProdNoExist", $ligne[0])."\n";
                             		break;*/
                             case 'D':
                                 if ($pid > 0) {
                                     if ($doliprod->delete($pid) < 0) {
                                         $this->process_msg .= $langs->trans("ErrProductDelete", $ligne[0], $doliprod->error) . "\n";
                                         $error++;
                                     }
                                 } else {
                                     $this->process_msg .= $langs->trans("Untreated", $i) . ' ' . $langs->trans("ErrProdNoExist", $ligne[0]) . "\n";
                                 }
                         }
                         if (!$error) {
                             $this->db->commit();
                         } else {
                             $this->db->rollback();
                         }
                     }
                 }
                 // while
                 break;
             case 'ImportThirtdparty':
                 $i = 0;
                 //$societe = new Societe($this->db);
                 while ($ligne = fgetcsv($fp, 1000, ";")) {
                     $i++;
                     $societe = new Societe($this->db);
                     if ($this->firstline && $i == 1) {
                         continue;
                     }
                     if (!$ligne[0]) {
                         $this->process_msg .= $langs->trans("Untreated", $i) . " " . $langs->trans("ErrNameRequired") . "\n";
                         continue;
                     }
                     // vérifier par code_client
                     if ($ligne[13]) {
                         $sid = $this->get_socbyclientcode($ligne[13]);
                     } else {
                         if ($ligne[14]) {
                             $sid = $this->get_socbysuplliercode($ligne[14]);
                         }
                     }
                     if ($sid > 0) {
                         $societe->fetch($sid);
                     } else {
                         $sid = $societe->fetch('', $ligne[0]);
                     }
                     if ($ligne[12]) {
                         $pid = dol_getIdFromCode($this->db, $ligne[12], "c_pays", "code", "rowid");
                     } else {
                         $pid = '';
                     }
                     if ($pid <= 0) {
                         $pid = '';
                     }
                     $did = '';
                     $societe->id = $sid;
                     $societe->name = $ligne[0];
                     $societe->particulier = 0;
                     //Société
                     $societe->address = $ligne[1] . "\n" . $ligne[2] . "\n" . $ligne[3];
                     $societe->zip = $ligne[4];
                     $societe->town = $ligne[5];
                     $societe->state_id = $did;
                     if ($ligne[12]) {
                         $societe->country_code = $ligne[12];
                     }
                     $societe->country_id = $pid;
                     dol_syslog("codes {$pid} " . $lige[12], LOG_DEBUG);
                     $societe->phone = $ligne[6];
                     $societe->fax = $ligne[7];
                     $societe->email = $ligne[8];
                     $societe->url = $ligne[9];
                     $societe->idprof1 = $ligne[10];
                     switch ($ligne[11]) {
                         case '0':
                             $societe->fournisseur = 0;
                             $societe->client = $ligne[11];
                             break;
                         case '1':
                             $societe->fournisseur = 0;
                             $societe->client = $ligne[11];
                             break;
                         case '2':
                             $societe->fournisseur = 0;
                             $societe->client = $ligne[11];
                             break;
                         case '10':
                             $societe->client = 0;
                             $societe->fournisseur = 1;
                             break;
                         default:
                             break;
                     }
                     if ($ligne[13]) {
                         $societe->code_client = $ligne[13];
                     }
                     if ($ligne[14]) {
                         $societe->code_fournisseur = $ligne[14];
                     }
                     /*if ($ligne[15]) $societe->array_options["options_zone"]=$ligne[15];
                     				if (!empty($ligne[16])) $societe->array_options["options_CA"]=$ligne[16];
                     
                     				if (!empty($ligne[17]))
                     				{
                     					   if ($ligne[17] <= 5) $societe->effectif_id = 1;
                     					   elseif ($ligne[17] <= 10) $societe->effectif_id = 2;
                     					   elseif ($ligne[17] <= 50) $societe->effectif_id = 3;
                     					   elseif ($ligne[17] <= 100) $societe->effectif_id = 4;
                     					   elseif ($ligne[17] <= 500) $societe->effectif_id = 5;
                     					   else $societe->effectif_id = 7;
                     				}
                     				dol_syslog("effectif " . $lige[17].'  '.$societe->effectif_id." ".print_r($societe->array_options, true), LOG_DEBUG);*/
                     $this->db->begin;
                     switch ($typeimport) {
                         case 'C':
                             if ($sid > 0) {
                                 if ($societe->update($sid, $this->user) < 0) {
                                     $this->process_msg .= $langs->trans("ErrCompanyUpdate", $ligne[0], $societe->error) . "\n";
                                     $error++;
                                 }
                             } elseif ($societe->create($this->user) < 0) {
                                 $this->process_msg .= $langs->trans("ErrCompanyCreate", $ligne[0], $societe->error) . "\n";
                                 $error++;
                             }
                             break;
                             /*case 'M':
                             		if ($sid>0) 
                             		{
                             			if ($societe->update($sid, $this->user) < 0){
                             				$this->process_msg .= $langs->trans("ErrCompanyUpdate", $ligne[0], $societe->error)."\n";
                             				$error++;
                             			}
                             		}
                             		else $this->process_msg .= $langs->trans("Untreated", $i).' '.$langs->trans("CompanyNoExist", $ligne[0])."\n";
                             		break;*/
                         /*case 'M':
                         		if ($sid>0) 
                         		{
                         			if ($societe->update($sid, $this->user) < 0){
                         				$this->process_msg .= $langs->trans("ErrCompanyUpdate", $ligne[0], $societe->error)."\n";
                         				$error++;
                         			}
                         		}
                         		else $this->process_msg .= $langs->trans("Untreated", $i).' '.$langs->trans("CompanyNoExist", $ligne[0])."\n";
                         		break;*/
                         case 'D':
                             if ($sid > 0) {
                                 if ($societe->delete($sid) < 0) {
                                     $this->process_msg .= $langs->trans("ErrCompanyDelete", $ligne[0], $societe->error) . "\n";
                                     $error++;
                                 }
                             } else {
                                 $this->process_msg .= $langs->trans("Untreated", $i) . ' ' . $langs->trans("CompanyNoExist", $ligne[0]) . "\n";
                             }
                     }
                     if (!$error) {
                         $this->db->commit();
                     } else {
                         $this->db->rollback();
                     }
                 }
                 break;
             case 'ImportContact':
                 $i = 0;
                 //$contact=new Contact($this->db);
                 //$societe = new Societe($this->db);
                 while ($ligne = fgetcsv($fp, 1000, ";")) {
                     $i++;
                     $contact = new Contact($this->db);
                     $societe = new Societe($this->db);
                     if ($this->firstline && $i == 1) {
                         continue;
                     }
                     //if ($societe->fetch('',$ligne[0]) < 0 ) $this->process_msg .= "erreur lecture Société "."\n";
                     if ($ligne[0]) {
                         $socid = $this->get_socbyclientcode($ligne[0]);
                     } else {
                         if ($ligne[1]) {
                             $socid = $this->get_socbysuplliercode($ligne[1]);
                         }
                     }
                     if ($socid < 0) {
                         $this->process_msg .= $i . " " . $langs->trans("ErrCompanyRequired") . "\n";
                     } else {
                         $societe->fetch($socid);
                     }
                     if (!$societe->id) {
                         $this->process_msg .= $langs->trans("ErrCompanyNoExist", $ligne[0] . " " . $ligne[1]) . "\n";
                         continue;
                     }
                     if (empty($ligne[2])) {
                         $this->process_msg .= $langs->trans("Untreated", $i) . " " . $langs->trans("ErrNameRequired") . "\n";
                         continue;
                     }
                     $contactid = $this->get_contact_id($socid, $ligne[2], $ligne[3]);
                     $contact->id = $contactid;
                     $contact->civilite_id = $ligne[4];
                     $contact->lastname = $ligne[2];
                     $contact->firstname = $ligne[3];
                     if ($ligne[5] || $ligne[6] || $ligne[7]) {
                         $contact->address = $ligne[5] . "\n" . $ligne[6] . "\n" . $ligne[7];
                     } else {
                         $contact->address = $societe->address;
                     }
                     if ($ligne[8]) {
                         $contact->zip = $ligne[8];
                     } else {
                         $contact->zip = $societe->zip;
                     }
                     if ($ligne[9]) {
                         $contact->town = $ligne[9];
                     } else {
                         $contact->town = $societe->town;
                     }
                     if ($ligne[10]) {
                         $pid = dol_getIdFromCode($this->db, $ligne[10], "c_pays", "code", "rowid");
                         if ($pid <= 0) {
                             $pid = '';
                         }
                         $contact->country_id = $pid;
                         $contact->country_code = $ligne[10];
                     } else {
                         $contact->country_id = $societe->country_id;
                         $contact->country_code = $societe->country_code;
                     }
                     $contact->socid = $socid;
                     // fk_soc
                     $contact->status = 1;
                     $contact->email = $ligne[11];
                     $contact->phone_pro = $ligne[12];
                     $contact->fax = $ligne[13];
                     $contact->phone_mobile = $ligne[14];
                     $contact->priv = 0;
                     $this->db - begin;
                     switch ($typeimport) {
                         case 'C':
                             if ($contactid > 0) {
                                 if ($contact->update($contactid, $this->user) < 0) {
                                     $this->process_msg .= $langs->trans("ErrContactUpdate", $ligne[2], $contact->error) . "\n";
                                     $error++;
                                 }
                             } elseif ($contact->create($this->user) < 0) {
                                 $this->process_msg .= $langs->trans("ErrContactCreate", $ligne[2], $contact->error) . "\n";
                                 $error++;
                             }
                             break;
                             /*case 'M':
                             		if ($contactid>0) 
                             		{
                             			if ($contact->update($contactid, $this->user) < 0){
                             				$this->process_msg .= $langs->trans("ErrContactUpdate", $ligne[2], $contact->error)."\n";
                             				$error++;
                             			}
                             		}
                             		else $this->process_msg .= $langs->trans("Untreated", $i).' '.$langs->trans("ContactNoExist", $ligne[2])."\n";
                             		break;*/
                         /*case 'M':
                         		if ($contactid>0) 
                         		{
                         			if ($contact->update($contactid, $this->user) < 0){
                         				$this->process_msg .= $langs->trans("ErrContactUpdate", $ligne[2], $contact->error)."\n";
                         				$error++;
                         			}
                         		}
                         		else $this->process_msg .= $langs->trans("Untreated", $i).' '.$langs->trans("ContactNoExist", $ligne[2])."\n";
                         		break;*/
                         case 'D':
                             if ($contactid > 0) {
                                 if ($contact->delete($contactid) < 0) {
                                     $this->process_msg .= $langs->trans("ErrContactDelete", $ligne[2], $contact->error) . "\n";
                                     $error++;
                                 }
                             } else {
                                 $this->process_msg .= $langs->trans("Untreated", $i) . ' ' . $langs->trans("ContactNoExist", $ligne[2]) . "\n";
                             }
                     }
                     if (!$error) {
                         $this->db->commit();
                     } else {
                         $this->db->rollback();
                     }
                 }
                 break;
                 /*case 'ImportActions':
                 			$i=0;
                 			$contact=new Contact($this->db);
                 			$societe = new Societe($this->db);
                 			$actioncomm = new ActionComm($this->db);
                 			$actuser = new User($this->db);
                 			
                 			while ($ligne = fgetcsv($fp,1000,";"))
                 			{
                 				$i++;
                 				if ($this->firstline && $i== 1) continue;
                 				
                 				//if ($societe->fetch('',$ligne[0]) < 0 ) $this->process_msg .= "erreur lecture Société "."\n";
                 				//else $socid = $societe->id;
                 				$socid = $this->get_socbyclientcode($ligne[0]);
                 				if ($socid < 0 ) $this->process_msg .= $langs->trans("Untreated", $i).' '.$langs->trans("ErrCompanyRequired")."\n";
                 				else $societe->fetch($socid);
                 				$socid = $societe->id;
                 				
                 				if (!$socid) 
                 				{
                 					$this->process_msg .= $langs->trans("ErrCompanyNoExist", $ligne[0])."\n";
                 					continue;
                 				}
                 								
                 				//action sur un contact de la soc
                 				if ($ligne[1])
                 				{
                 					$contactid = $this->get_contact_id($socid, $ligne[1], $ligne[2]) ;
                 					
                 					if ($contactid < 0) {
                 						$this->process_msg .= $langs->trans("Untreated", $i).' '.$langs->trans("ContactNoExist", $ligne[1].' '. $ligne[2])."\n";
                 						// réinitialiser ??
                 						continue;
                 					}
                 					else $contact->fetch($contactid);
                 					
                 				}
                 				
                 
                 				$usertodo = '';
                 				if ($ligne[9])
                 				{
                 					$usertodo=new User($this->db);
                 					if ( $usertodo->fetch('',$ligne[9]) < 0 ) $this->process_msg .= $langs->trans("ErrUserNoExist", $ligne[9])."\n";
                 				}
                 				$userdone= '' ;
                 				if ($ligne[10])
                 				{
                 					$usertodo=new User($this->db);
                 					if ( $usertodo->fetch('',$ligne[10]) < 0 ) $this->process_msg .= $langs->trans("ErrUserNoExist", $ligne[10])."\n";
                 					
                 				}
                 				$datep = '';
                 				if ($ligne[6])
                 				{
                 					// voir date
                 					$n = sscanf($ligne[6],"%02d/%02d/%04d", $d_day, $d_mon, $d_year);
                 					if ($n==3) $datep=dol_mktime(12, 0, 0, $d_mon, $d_day, $d_year);
                 					if (!$datep) $this->process_msg .= $langs->trans("ErrDateConversion", $ligne[6])."\n";
                 				}
                 				else $datep ='';
                 				$datef='';
                 				if ($ligne[7])
                 				{
                 					// voir la date
                 					$n = sscanf($ligne[7],"%02d/%02d/%04d", $d_day, $d_mon, $d_year);
                 					if ($n==3)$datef=dol_mktime(12, 0, 0, $d_mon, $d_day, $d_year);
                 					if (!$datef) $this->process_msg .= $langs->trans("ErrDateConversion", $ligne[7])."\n";
                 				}
                 				else $datef ='';
                 				//$datef='';
                 				$actioncomm->societe = $societe;
                 				if ($ligne[1]) $actioncomm->contact = $contact;
                 				else $actioncomm->contact = '';
                 				$actioncomm->type_code = $ligne[3];
                 				$actioncomm->priority = $ligne[4];
                 				$actioncomm->location = '' ;
                 				$actioncomm->label = $ligne[5];
                 				$actioncomm->datep = $datep;
                 				$actioncomm->datef = $datef;
                 				$actioncomm->percentage = $ligne[8];
                 				$actioncomm->usertodo = $usertodo;
                 				$actioncomm->userdone = $userdone;
                 				$actioncomm->note =$ligne[11];
                 				
                 				switch ($typeimport)
                 				{					
                 				case 'C':
                 					$this->db->begin();
                 					if ($actioncomm->add($this->user) < 0) 
                 					{ 
                 						$this->process_msg .= $langs->trans("ErrActionCreate", $ligne[5], $actioncomm->error)."\n";
                 						$this->db->rollback();
                 					}
                 					else $this->db->commit();
                 					break;
                 				case 'M':
                 					$this->db->begin();
                 					if($actioncomm->update($user) < 0){
                 						$this->process_msg .= $langs->trans("ErrActionUpdate", $ligne[5], $actioncomm->error)."\n";
                 						$this->db->rollback();
                 					}
                 					else $this->db->commit();
                 					break;
                 				case 'D':
                 					$this->db->begin();
                 					if($actioncomm->delete() < 0){
                 						$this->process_msg .= $langs->trans("ErrActionDelete", $ligne[5], $actioncomm->error)."\n";
                 						$this->db->rollback();
                 					}
                 					else $this->db->commit();
                 					break;
                 				}
                 			}
                 				
                 			break;*/
             /*case 'ImportActions':
             			$i=0;
             			$contact=new Contact($this->db);
             			$societe = new Societe($this->db);
             			$actioncomm = new ActionComm($this->db);
             			$actuser = new User($this->db);
             			
             			while ($ligne = fgetcsv($fp,1000,";"))
             			{
             				$i++;
             				if ($this->firstline && $i== 1) continue;
             				
             				//if ($societe->fetch('',$ligne[0]) < 0 ) $this->process_msg .= "erreur lecture Société "."\n";
             				//else $socid = $societe->id;
             				$socid = $this->get_socbyclientcode($ligne[0]);
             				if ($socid < 0 ) $this->process_msg .= $langs->trans("Untreated", $i).' '.$langs->trans("ErrCompanyRequired")."\n";
             				else $societe->fetch($socid);
             				$socid = $societe->id;
             				
             				if (!$socid) 
             				{
             					$this->process_msg .= $langs->trans("ErrCompanyNoExist", $ligne[0])."\n";
             					continue;
             				}
             								
             				//action sur un contact de la soc
             				if ($ligne[1])
             				{
             					$contactid = $this->get_contact_id($socid, $ligne[1], $ligne[2]) ;
             					
             					if ($contactid < 0) {
             						$this->process_msg .= $langs->trans("Untreated", $i).' '.$langs->trans("ContactNoExist", $ligne[1].' '. $ligne[2])."\n";
             						// réinitialiser ??
             						continue;
             					}
             					else $contact->fetch($contactid);
             					
             				}
             				
             
             				$usertodo = '';
             				if ($ligne[9])
             				{
             					$usertodo=new User($this->db);
             					if ( $usertodo->fetch('',$ligne[9]) < 0 ) $this->process_msg .= $langs->trans("ErrUserNoExist", $ligne[9])."\n";
             				}
             				$userdone= '' ;
             				if ($ligne[10])
             				{
             					$usertodo=new User($this->db);
             					if ( $usertodo->fetch('',$ligne[10]) < 0 ) $this->process_msg .= $langs->trans("ErrUserNoExist", $ligne[10])."\n";
             					
             				}
             				$datep = '';
             				if ($ligne[6])
             				{
             					// voir date
             					$n = sscanf($ligne[6],"%02d/%02d/%04d", $d_day, $d_mon, $d_year);
             					if ($n==3) $datep=dol_mktime(12, 0, 0, $d_mon, $d_day, $d_year);
             					if (!$datep) $this->process_msg .= $langs->trans("ErrDateConversion", $ligne[6])."\n";
             				}
             				else $datep ='';
             				$datef='';
             				if ($ligne[7])
             				{
             					// voir la date
             					$n = sscanf($ligne[7],"%02d/%02d/%04d", $d_day, $d_mon, $d_year);
             					if ($n==3)$datef=dol_mktime(12, 0, 0, $d_mon, $d_day, $d_year);
             					if (!$datef) $this->process_msg .= $langs->trans("ErrDateConversion", $ligne[7])."\n";
             				}
             				else $datef ='';
             				//$datef='';
             				$actioncomm->societe = $societe;
             				if ($ligne[1]) $actioncomm->contact = $contact;
             				else $actioncomm->contact = '';
             				$actioncomm->type_code = $ligne[3];
             				$actioncomm->priority = $ligne[4];
             				$actioncomm->location = '' ;
             				$actioncomm->label = $ligne[5];
             				$actioncomm->datep = $datep;
             				$actioncomm->datef = $datef;
             				$actioncomm->percentage = $ligne[8];
             				$actioncomm->usertodo = $usertodo;
             				$actioncomm->userdone = $userdone;
             				$actioncomm->note =$ligne[11];
             				
             				switch ($typeimport)
             				{					
             				case 'C':
             					$this->db->begin();
             					if ($actioncomm->add($this->user) < 0) 
             					{ 
             						$this->process_msg .= $langs->trans("ErrActionCreate", $ligne[5], $actioncomm->error)."\n";
             						$this->db->rollback();
             					}
             					else $this->db->commit();
             					break;
             				case 'M':
             					$this->db->begin();
             					if($actioncomm->update($user) < 0){
             						$this->process_msg .= $langs->trans("ErrActionUpdate", $ligne[5], $actioncomm->error)."\n";
             						$this->db->rollback();
             					}
             					else $this->db->commit();
             					break;
             				case 'D':
             					$this->db->begin();
             					if($actioncomm->delete() < 0){
             						$this->process_msg .= $langs->trans("ErrActionDelete", $ligne[5], $actioncomm->error)."\n";
             						$this->db->rollback();
             					}
             					else $this->db->commit();
             					break;
             				}
             			}
             				
             			break;*/
             case 'Importtarif':
                 // ref four
                 $i = 0;
                 $this->process_msg = '';
                 $error = 0;
                 /*$doliprod = new Product($this->db);
                 		$product = new ProductFournisseur($this->db);
                 		$societe = new Societe($this->db);*/
                 while ($ligne = fgetcsv($fp, 1000, ";")) {
                     $doliprod->id = '';
                     $i++;
                     $doliprod = new Product($this->db);
                     $product = new ProductFournisseur($this->db);
                     $societe = new Societe($this->db);
                     if ($this->firstline && $i == 1) {
                         continue;
                     }
                     // recherche du fournisseur
                     if ($societe->fetch('', $ligne[2]) > 0) {
                         $sid = $societe->id;
                     } else {
                         $this->process_msg .= $langs->trans("Untreated", $i) . " " . $langs->trans("ErrComppanyNoExist", $ligne[2]) . "\n";
                         $sid = '';
                     }
                     if ($doliprod->fetch('', $ligne[0]) > 0) {
                         $pid = $doliprod->id;
                     } else {
                         $this->process_msg .= $langs->trans("Untreated", $i) . " " . $langs->trans("ErrProductNoExist", $ligne[0], $doliprod->error) . "\n";
                         $pid = '';
                     }
                     if ($sid > 0 && $pid > 0) {
                         $result = $product->fetch($doliprod->id);
                         if ($result > 0) {
                             $this->db->begin();
                             switch ($typeimport) {
                                 case 'C':
                                     $ret = $product->add_fournisseur($this->user, $sid, $ligne[1], $ligne[3]);
                                     if ($ret < 0 && $ret != -3) {
                                         $this->process_msg .= $langs->trans("Untreated", $i) . " " . $langs->trans("ErrCreatePrice", $product->error) . "\n";
                                         $error++;
                                     }
                                     $ret = $product->update_buyprice($ligne[3], $ligne[4], $this->user, 'HT', $supplier, '', $ligne[1], $ligne[5]);
                                     if ($ret < 0 && $ret != -3) {
                                         $this->process_msg .= $langs->trans("Untreated", $i) . " " . $langs->trans("ErrCreatePrice", $product->error) . "\n";
                                         $error++;
                                     }
                                     break;
                                     /*case 'M':
                                     		{
                                     			// gestion du prix obligatoire
                                     			$supplier=new Fournisseur($this->db);
                                     			$result=$supplier->fetch($sid);
                                     			
                                     			$ret=$product->update_buyprice($ligne[3], $ligne[4] , $this->user, 'HT', $supplier, '', $ligne[1], $ligne[5] );
                                     			if ($ret < 0)
                                     			{
                                     				$this->process_msg .= $langs->trans("Untreated", $i)." ".$langs->trans("Qty").$ligne[3]. ", ".$langs->trans("Price").$ligne[4]." ".$langs->trans("ErrUpdatePrice", $product->error)."\n";
                                     				$error ++;
                                     			}
                                     			
                                     		}
                                     		break;*/
                                 /*case 'M':
                                 		{
                                 			// gestion du prix obligatoire
                                 			$supplier=new Fournisseur($this->db);
                                 			$result=$supplier->fetch($sid);
                                 			
                                 			$ret=$product->update_buyprice($ligne[3], $ligne[4] , $this->user, 'HT', $supplier, '', $ligne[1], $ligne[5] );
                                 			if ($ret < 0)
                                 			{
                                 				$this->process_msg .= $langs->trans("Untreated", $i)." ".$langs->trans("Qty").$ligne[3]. ", ".$langs->trans("Price").$ligne[4]." ".$langs->trans("ErrUpdatePrice", $product->error)."\n";
                                 				$error ++;
                                 			}
                                 			
                                 		}
                                 		break;*/
                                 case 'D':
                                     // suprresion de la ligne avec le même nb d'article et le même prix
                                     $sql = "SELECT pfp.rowid FROM " . MAIN_DB_PREFIX . "product_fournisseur_price as pfp";
                                     $sql .= " WHERE pfp.quantity = '" . $ligne[3] . "' AND pfp.ref_fourn = '" . $ligne[1];
                                     $sql .= "' AND pfp.fk_soc = '" . $sid . "' AND pfp.fk_product='" . $pid . "'";
                                     $sql .= " AND pfp.entity = " . $conf->entity;
                                     $resql = $this->db->query($sql);
                                     if ($resql) {
                                         $obj = $this->db->fetch_object($resql);
                                         if ($obj->rowid > 0) {
                                             $result = $product->remove_product_fournisseur_price($obj->rowid);
                                         } else {
                                             $this->process_msg .= $langs->trans("Untreated", $i) . ' ' . $langs->trans("ErrDeletePrice", $product->error) . "\n";
                                             $error++;
                                         }
                                     } else {
                                         $this->process_msg .= "Error SQL= " . $sql . "\n";
                                         $error++;
                                     }
                                     break;
                             }
                             //switch
                         }
                         if (!$error) {
                             $this->db->commit();
                         } else {
                             $this->db->rollback();
                         }
                     }
                     // fournisseur trouvé
                 }
                 // traitement ligne
                 // while reffour
                 break;
         }
         // fin switch
         fclose($fp);
     } else {
         $this->error = $langs->trans("ErrOpenFile") . $nomfich;
         $error = -1;
     }
     return $error;
 }
コード例 #8
0
ファイル: SocieteTest.php プロジェクト: nrjacker4/crm-php
    /**
     * testSocieteUpdate
     *
     * @param	Societe	$localobject	Company
     * @return	Societe	$localobject	Company
	 *
     * @depends	testSocieteFetch
     * The depends says test is run only if previous is ok
     */
    public function testSocieteUpdate($localobject)
    {
    	global $conf,$user,$langs,$db;
		$conf=$this->savconf;
		$user=$this->savuser;
		$langs=$this->savlangs;
		$db=$this->savdb;

		$localobject->note='New note after update';
		//$localobject->note_public='New note public after update';
		$localobject->name='New name';
		$localobject->address='New address';
		$localobject->zip='New zip';
		$localobject->town='New town';
		$localobject->country_id=2;
		$localobject->status=0;
		$localobject->tel='New tel';
		$localobject->fax='New fax';
		$localobject->email='*****@*****.**';
		$localobject->url='New url';
		$localobject->idprof1='new idprof1';
		$localobject->idprof2='new idprof2';
		$localobject->idprof3='new idprof3';
		$localobject->idprof4='new idprof4';
		$result=$localobject->update($localobject->id,$user);
    	print __METHOD__." id=".$localobject->id." result=".$result."\n";
    	$this->assertLessThan($result, 0);
		$result=$localobject->update_note($localobject->note);
    	print __METHOD__." id=".$localobject->id." result=".$result."\n";
    	$this->assertLessThan($result, 0);
		//$result=$localobject->update_note_public($localobject->note_public);
    	//print __METHOD__." id=".$localobject->id." result=".$result."\n";
    	//$this->assertLessThan($result, 0);

		$newobject=new Societe($this->savdb);
    	$result=$newobject->fetch($localobject->id);
        print __METHOD__." id=".$localobject->id." result=".$result."\n";
    	$this->assertLessThan($result, 0);

    	$this->assertEquals($localobject->note, $newobject->note);
    	//$this->assertEquals($localobject->note_public, $newobject->note_public);
    	$this->assertEquals($localobject->name, $newobject->name);
    	$this->assertEquals($localobject->address, $newobject->address);
    	$this->assertEquals($localobject->zip, $newobject->zip);
    	$this->assertEquals($localobject->town, $newobject->town);
    	$this->assertEquals($localobject->country_id, $newobject->country_id);
    	$this->assertEquals('BE', $newobject->country_code);
    	$this->assertEquals($localobject->status, $newobject->status);
    	$this->assertEquals($localobject->tel, $newobject->tel);
    	$this->assertEquals($localobject->fax, $newobject->fax);
    	$this->assertEquals($localobject->email, $newobject->email);
    	$this->assertEquals($localobject->url, $newobject->url);
    	$this->assertEquals($localobject->idprof1, $newobject->idprof1);
    	$this->assertEquals($localobject->idprof2, $newobject->idprof2);
    	$this->assertEquals($localobject->idprof3, $newobject->idprof3);
    	$this->assertEquals($localobject->idprof4, $newobject->idprof4);

    	return $localobject;
    }