num_acte = $num_acte; $this->num_acte_lie = $num_acte_lie; if (!$num_acte || !$num_acte_lie) die ("Erreur de création liens_actes"); $q = "select count(1) from liens_actes where num_acte = '".$num_acte."' and num_acte_lie = '".$num_acte_lie."' "; $r = mysql_query($q, $dbh); if (mysql_result($r, 0, 0) == 0) { $q = "insert into liens_actes set num_acte = '".$num_acte."', num_acte_lie = '".$num_acte_lie."' "; $r = mysql_query($q, $dbh); } } //supprime un lien entre actes de la base function delete($num_acte) { global $dbh; $q = "delete from liens_actes where num_acte = '".$num_acte."' or num_acte_lie = '".$num_acte."' "; $r = mysql_query($q, $dbh); } //recherche l'acte pere de l'acte passé en paramètre static function getParent($num_acte_lie) { global $dbh; $q = "select num_acte from liens_actes where num_acte_lie = '".$num_acte_lie."' limit 1"; $r = mysql_query($q, $dbh); if (mysql_num_rows($r)) return mysql_result($r, 0, 0); else return '0'; } //recherche du devis origine de l'acte passe en parametre static function getDevis($num_acte_lie) { global $dbh; $q = "select num_acte from liens_actes join actes on num_acte=id_acte and type_acte = '".TYP_ACT_DEV."' where num_acte_lie = '".$num_acte_lie."' limit 1"; $r = mysql_query($q, $dbh); if (mysql_num_rows($r)) return mysql_result($r, 0, 0); else return '0'; } //recherche la commande du bl/facture passe en parametre static function getOrder($num_acte_lie) { global $dbh; $q = "select num_acte from liens_actes join actes on num_acte=id_acte and type_acte = '".TYP_ACT_CDE."' where num_acte_lie = '".$num_acte_lie."' limit 1"; $r = mysql_query($q, $dbh); if (mysql_num_rows($r)) return mysql_result($r, 0, 0); else return '0'; } //recherche les enfants de l'acte passé en paramètre static function getChilds($num_acte, $type_acte=TYP_ACT_ALL) { global $dbh; $q = "select num_acte_lie, numero, type_acte, statut from liens_actes, actes where num_acte = '".$num_acte."' and id_acte = num_acte_lie "; if ($type_acte != TYP_ACT_ALL) $q.= "and type_acte = '".$type_acte."' "; $q.= "order by type_acte, numero"; $r = mysql_query($q, $dbh); return $r; } //recherche les livraisons pour une commande //retourne un tableau d'ids static function getDeliveries ($num_cde, $with_date=false) { global $dbh; $t=array(); $q = "select num_acte_lie from liens_actes join actes on num_acte_lie = id_acte and type_acte = '".TYP_ACT_LIV."' "; $q.= "where num_acte = '".$num_cde."' "; if($with_date) { "and date_acte = '".$with_date."' "; } $q.= "order by numero desc"; $r = mysql_query($q, $dbh); if (mysql_num_rows($r)) { while($row=mysql_fetch_object($r)) { $t[]=$row->num_acte_lie; } } return $t; } //optimization de la table liens_actes function optimize() { global $dbh; $opt = mysql_query('OPTIMIZE TABLE liens_actes', $dbh); return $opt; } } ?>