Jump to content

Help SQL custom


haki

Recommended Posts

Bonjour , je voulais ajouter une nouvelle colone Responsable ( afficher la dernière personne qui à ajouter une action dans la commande ) dans la partie des commandes Backend.  J'ai apporter des modifications dans le AdminOrdersController.php mais depuis que j'ai ajouter j'ai les commandes en doubles comment faire pour ne plus avoir les deoublons.

 

    $this->_select = '

		a.id_currency,
		a.id_order AS id_pdf,
		
		
		CONCAT(LEFT(c.`firstname`, 1), \'. \', c.`lastname`) AS `customer`,
		osl.`name` AS `osname`,
		
		CONCAT(LEFT(emp.`firstname`, 1), \'. \', emp.`lastname`) AS `nametech`,
		
		
		os.`color`,
		IF((SELECT so.id_order FROM `'._DB_PREFIX_.'orders` so WHERE so.id_customer = a.id_customer AND so.id_order < a.id_order LIMIT 1) > 0, 0, 1) as new,
		cl.name as cname,
		IF(a.valid, 1, 0) badge_success';

        $this->_join = '
		LEFT JOIN `'._DB_PREFIX_.'customer` c ON (c.`id_customer` = a.`id_customer`)
		LEFT JOIN `'._DB_PREFIX_.'address` address ON address.id_address = a.id_address_delivery
		LEFT JOIN `'._DB_PREFIX_.'country` country ON address.id_country = country.id_country
		LEFT JOIN `'._DB_PREFIX_.'country_lang` cl ON (country.`id_country` = cl.`id_country` AND cl.`id_lang` = '.(int)$this->context->language->id.')
		LEFT JOIN `'._DB_PREFIX_.'order_state` os ON (os.`id_order_state` = a.`current_state`)
	
		
		LEFT JOIN `'._DB_PREFIX_.'order_history` oh ON (oh.`id_order` = a.`id_order`)
		LEFT JOIN `'._DB_PREFIX_.'employee` emp ON (oh.`id_employee` = emp.`id_employee`)
		
		LEFT JOIN `'._DB_PREFIX_.'order_state_lang` osl ON (os.`id_order_state` = osl.`id_order_state` AND osl.`id_lang` = '.(int)$this->context->language->id.')

		';

		
		$this->_orderBy = 'id_order';
		
        $this->_orderWay = 'DESC';
        $this->_use_found_rows = true;

 

Link to comment
Share on other sites

Remplacer:

LEFT JOIN `'._DB_PREFIX_.'order_history` oh ON (oh.`id_order` = a.`id_order`)

Par:

INNER JOIN `'._DB_PREFIX_.'order_history` oh ON (oh.`id_order` = a.`id_order`)
LEFT JOIN `'._DB_PREFIX_.'order_history` oh2 ON (oh.`id_order` = a.`id_order` and oh2.id_order_history > oh.id_order_history)

Et ajouter:

WHERE oh2.id_order_history is null

 

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...