$group = CGroups::loadCurrent(); $ljoin = array(); $ljoin["sallesbloc"] = "`sallesbloc`.`bloc_id` = `bloc_operatoire`.`bloc_operatoire_id`"; $where = array(); $where["bloc_operatoire.group_id"] = "= '{$group->_id}'"; $where["sallesbloc.salle_id"] = "IS NULL"; $order = "bloc_operatoire.nom"; $bloc = new CBlocOperatoire(); $success_count = 0; $failures = array(); $blocs = array(); if ($purge) { /** @var CBlocOperatoire[] $blocs */ $blocs = $bloc->loadList($where, $order, $max, null, $ljoin); foreach ($blocs as $_bloc) { if ($msg = $_bloc->delete()) { $failures[$_bloc->_id] = $msg; continue; } $success_count++; } } $count = $bloc->countList($where, null, $ljoin); $smarty = new CSmartyDP(); $smarty->assign("blocs", $blocs); $smarty->assign("purge", $purge); $smarty->assign("max", $max); $smarty->assign("count", $count); $smarty->assign("success_count", $success_count); $smarty->assign("failures", $failures); $smarty->display("purge_empty_blocsop.tpl");
/** @var CBlocOperatoire[] $blocs */ $blocs = $bloc->loadList($where, $order, $max); foreach ($blocs as $_bloc) { $back_props = 0; $back_props += $_bloc->countBackRefs('salles'); $back_props += $_bloc->countBackRefs('check_lists'); $back_props += $_bloc->countBackRefs('stock_locations'); $back_props += $_bloc->countBackRefs('postes'); $back_props += $_bloc->countBackRefs('check_list_categories'); $back_props += $_bloc->countBackRefs('check_list_type_links'); $back_props += $_bloc->countBackRefs('product_address_orders'); $back_props += $_bloc->countBackRefs('origine_brancardage'); $back_props += $_bloc->countBackRefs('origine_item'); if (!$back_props) { if ($msg = $_bloc->delete()) { $failures[$_bloc->_id] = $msg; continue; } $success_count++; } } } $count = $bloc->countList($where); $smarty = new CSmartyDP(); $smarty->assign("blocs", $blocs); $smarty->assign("purge", $purge); $smarty->assign("max", $max); $smarty->assign("count", $count); $smarty->assign("success_count", $success_count); $smarty->assign("failures", $failures); $smarty->display("purge_empty_blocsop.tpl");