stephan Posted September 20, 2009 Share Posted September 20, 2009 Dans la même lignée je souhaite emmettre mes n° de bordereau sous ce format :Anné N° dans l'année2009xxxxxxxMême bétise : on corrige la structure des tables pour accepter les entiers long ALTER TABLE `ps_orders` CHANGE `delivery_number` `delivery_number` BIGINT( 10 ) UNSIGNED NOT NULL DEFAULT '0' Link to comment Share on other sites More sharing options...
stephan Posted September 20, 2009 Author Share Posted September 20, 2009 Modification du fichier Order.php dans class public function setDelivery() { /* // Set delivery number $this->delivery_number = intval(Configuration::get('PS_DELIVERY_NUMBER')); Configuration::updateValue('PS_DELIVERY_NUMBER', $this->delivery_number + 1); if (!intval($this->delivery_number)) die(Tools::displayError('Invalid delivery number')); // Set delivery date $this->delivery_date = date('Y-m-d H:i:s'); // Update object $this->update(); */ // Set delivery number //#BORDEREAU $DeliveryNumberString = Configuration::get('PS_DELIVERY_NUMBER'); // Récupère le nouveau numéro de livraison $DeliveryNumber = substr ( $DeliveryNumberString , 6 ); // Extrait le numéro de Bordereau $MonthNumber = substr ( $DeliveryNumberString , 4, 2 ); // Récupère le Mois $YearNumber = substr ( $DeliveryNumberString , 0, 4 ); // Récupère l'Année if ( ($MonthNumber != date("m")) || ($YearNumber != date("Y"))){ $DeliveryNumber =1 ;} // Change de mois ou d'année, ou passe à 1 $DeliveryNumberString = date("Ym"). str_repeat("0", (4 - strlen ("$DeliveryNumber"))). $DeliveryNumber; // Reconstruit le numéro de Bordereau avec la date $this->delivery_number = $DeliveryNumberString; // Envoie le numéro de Bordereau $this->delivery_date = date('Y-m-d H:i:s'); $this->update(); // On incrémente le numéro $DeliveryNumber = $DeliveryNumber + 1; // Met à jour le prochain numéro Configuration::updateValue('PS_DELIVERY_NUMBER', date("Ym"). str_repeat("0", (4 - strlen ("$DeliveryNumber"))) . $DeliveryNumber ); } //#BORDEREAU //echo 'delivery_number).'">'; echo 'delivery_number .'">'; //#BORDEREAU //'WHERE `delivery_number` = '.intval($id_delivery)); 'WHERE `delivery_number` = '. $id_delivery ); //#BORDEREAU // $fields['delivery_number'] = intval($this->delivery_number); $fields['delivery_number'] = $this->delivery_number; Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now