0byt3m1n1
Path:
/
home
/
kassiope
/
www
/
administrer
/
class
/
[
Home
]
File: ajax_func.php
<?php $xajax = new xajax(); $xajax->registerFunction("load_color_size"); $xajax->registerFunction("change_prix"); $xajax->setCharEncoding('ISO-8859-1'); /* function change_prix_old($allline, $line) { $objResponse = new xajaxResponse(); $recprod = mysql_query_override("select * from gaia_produits where id = '".$allline['prodid'.$line]."'"); $pr = mysql_fetch_array_override($recprod); $newprix = $allline['p'.$line]; //$newprix = $newprix * $qte; $qte = $allline['q'.$line]; $newprix = $qte * $pr['prix']; if($allline['priv']=='reve') $newprix = $qte * $pr['prix_revendeur']; $objResponse->setCharEncoding('ISO-8859-1'); $objResponse->addAssign("p".$line,"value", number_format($newprix,2,'.','')); return $objResponse->getXML(); } */ function change_prix($allline, $line, $nbtot=false) { $objResponse = new xajaxResponse(); $recprod = mysql_query_override("select * from gaia_produits where id = '".$allline['l'.$line]."'"); $pr = mysql_fetch_array_override($recprod); $newprix = $allline['p'.$line]; //$newprix = $newprix * $qte; $nbprod = $allline['q'.$line]; if(!$nbtot) { $rectail = mysql_query_override("select * from gaia_tailles order by position"); while($pt = mysql_fetch_array_override($rectail)){ if(isset($allline['tail'.$line.'_'.$pt['id']])) $nbprod += $allline['tail'.$line.'_'.$pt['id']]; } } $objResponse->setCharEncoding('ISO-8859-1'); $objResponse->addAssign("q".$line,"value", $nbprod); $objResponse->addAssign("p".$line,"value", number_format($newprix,2,'.','')); $objResponse->addAssign("p9".$line,"value", number_format(($newprix*$nbprod),2,'.','')); return $objResponse->getXML(); } function load_color_size($id) { $sqlt = "select t.* from gaia_stocks s, gaia_tailles t where s.produit_id = '".$id."' and s.stock > 0 and s.taille_id = t.id group by taille_id"; $rectaille = mysql_query_override($sqlt); $sqlc = "select c.* from gaia_stocks s, gaia_couleurs c where s.produit_id = '".$id."' and s.stock > 0 and s.couleur_id = c.id group by couleur_id"; $reccouleur = mysql_query_override($sqlc); $rettaille = '<select name="taille" style="width:100px">'; if(mysql_num_rows_override($rectaille)>0) { while ($data = mysql_fetch_array_override($rectaille)) { $rettaille .= '<option value="'.$data['id'].'">'.stripslashes($data['nom_fr']).'</option>'; } } else $rettaille .= '<option value="0">--</option>'; $rettaille .= '</select>'; $retcouleur = '<select name="couleur" style="width:150px">'; if(mysql_num_rows_override($reccouleur)>0) { while ($data = mysql_fetch_array_override($reccouleur)) { $retcouleur .= '<option value="'.$data['id'].'">'.stripslashes($data['nom_fr']).'</option>'; } } else $retcouleur .= '<option value="0">--</option>'; $retcouleur .= '</select>'; $objResponse = new xajaxResponse(); $objResponse->setCharEncoding('ISO-8859-1'); $objResponse->addAssign("taille","innerHTML", $rettaille); $objResponse->addAssign("couleur","innerHTML", $retcouleur); return $objResponse->getXML(); } $xajax->processRequests(); ?>