Jump to content

Modification date_add dans ps_order_history


Recommended Posts

Bonjour bonjour !

 

Ça fait un bail que je n'ai pas posté ici, alors je reviens avec une petite question.

 

Bref, j'ai overridé un Prestashop 1.5 pour ajouter un chti peu d'ajax dans la vue de AdminOrdersController. Le but est de pouvoir modifier les états sur la fiche de commande (état, employé, date). Tout fonctionne bien sauf la date qui ne veut pas se modifier.

 

Voici le Ajax, qui tourne on ne peut mieux :

		$.ajax({
			type: 'POST',
			headers: { "cache-control": "no-cache" },
		    dataType: 'json',
		    url : 'ajax-tab.php',
			async: true,
		    data: {
		      controller: 'AdminOrders',
		      action: 'EditOrderState',
		      ajax: 1,
		      token: token,
		      edit_id_order: edit_id_order,
		      edit_date: edit_date,
		      id_order_history: id_order_history,
		      has_key: has_key,
		      new_id_order_history: new_id_order_history,
		      order_history_date: order_history_date,
		      new_employee: new_employee
		    },
		   success: function(response) {
				console.log(response);
				if (response = 'edited') {
					// location.reload();
				};
		   }
		});

Et mon AdminOrdersController :



	public function ajaxProcessEditOrderState(){
		$edit_id_history = Tools::getValue('id_order_history');
		$edit_id_order = Tools::getValue('edit_id_order');
		$edit_date = Tools::getValue('edit_date');
		$has_key = Tools::getValue('has_key');
		$order_history_date = Tools::getValue('order_history_date');
		$new_id_order_history = Tools::getValue('new_id_order_history');
		$new_employee = Tools::getValue('new_employee');
		$return = $this->editOrderState($edit_id_history, $new_id_order_history, $edit_id_order, $has_key, $order_history_date, $new_employee);
		echo Tools::jsonEncode($return);
	}

	protected function editOrderState($id_order_history, $new_id_order_history, $edit_id_order, $has_key, $order_history_date, $new_employee){
		$order_history_date = date('Y-m-d H:i:s', strtotime($order_history_date));
		$sql = 'UPDATE '._DB_PREFIX_.'order_history SET id_order_state = '.$new_id_order_history.', date_add = '.$order_history_date.', id_employee = '.$new_employee.' 
				WHERE id_order_history = '.$id_order_history;
		if (Db::getInstance()->execute($sql)){
			if (intval($has_key) != 0) {//What ???
					return('edited');
			} else {
				$sql_key = 'UPDATE '._DB_PREFIX_.'orders SET current_state = '.$new_id_order_history.' WHERE id_order = '.$edit_id_order;
				if (Db::getInstance()->execute($sql_key))
					return('edited');
			}
		} else{
			return('error inserting date');
		}
	}

Bon, je vous le donne en mille comme en cent, la date ne se modifie pas. Toutes les données sont bien envoyées, je me demande si y'a pas une c****le dans le pâté quelque part...

 

Des idées ?

 

Merci bien !

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...