protected function private_core() { /// ¿El usuario tiene permiso para eliminar en esta página? $this->allow_delete = $this->user->allow_delete_on(__CLASS__); $eje = new ejercicio(); $this->ejercicios = $eje->all(); $this->serie = new serie(); $fsvar = new fs_var(); if (isset($_GET['num_personalizada'])) { $this->num_personalizada = TRUE; $fsvar->simple_save('numeracion_personalizada', $this->num_personalizada); } else { $this->num_personalizada = $fsvar->simple_get('numeracion_personalizada'); } if (isset($_POST['codserie'])) { $serie = $this->serie->get($_POST['codserie']); if (!$serie) { $serie = new serie(); $serie->codserie = $_POST['codserie']; } $serie->descripcion = $_POST['descripcion']; $serie->siniva = isset($_POST['siniva']); $serie->irpf = floatval($_POST['irpf']); if ($this->num_personalizada) { $serie->codejercicio = NULL; $serie->numfactura = 1; if ($_POST['codejercicio'] != '') { $serie->codejercicio = $_POST['codejercicio']; $serie->numfactura = intval($_POST['numfactura']); } } if ($serie->save()) { $this->new_message("Serie " . $serie->codserie . " guardada correctamente"); } else { $this->new_error_msg("¡Imposible guardar la serie!"); } } else { if (isset($_GET['delete'])) { if (!$this->user->admin) { $this->new_error_msg('Sólo un administrador puede eliminar series.'); } else { $serie = $this->serie->get($_GET['delete']); if ($serie) { if ($serie->delete()) { $this->new_message('Serie eliminada correctamente.'); } else { $this->new_error_msg("¡Imposible eliminar la serie!"); } } else { $this->new_error_msg("Serie no encontrada."); } } } } }
public function addSerieAction(Request $request) { // Fonction pour la modification de l'utilisateur connecté // Récupère les informations de l'utilisateur connecté depuis la BDD $em = $this->getDoctrine()->getManager(); $newSerie = new serie(); // Formulaire pour la modification des infos $form = $this->createFormBuilder()->add('titre', 'text', array('label' => 'Titre : ', 'data' => ''))->add('nbSaisons', 'text', array('label' => 'Nombre de saison : ', 'data' => ''))->add('genre', 'text', array('label' => 'Genre : ', 'data' => ''))->add('description', 'text', array('label' => 'Description : ', 'data' => ''))->add('annee', 'text', array('label' => 'Date de création : ', 'data' => '', 'required' => false))->add('urlImage', 'text', array('label' => 'Url de l\'image : ', 'data' => '', 'required' => false))->add('sauvegarder', 'submit')->getForm(); $form->handleRequest($request); // Se lance lorsque le formulaire est soumis if ($form->isValid()) { $serie = $form->getData(); // Enregistre le nouveau titre dans la BDD $newSerie->setTitre($serie['titre']); // Enregistre le nouveau nbSaisons dans la BDD $newSerie->setNbSaisons($serie['nbSaisons']); // Enregistre le nouveau genre dans la BDD $newSerie->setGenre($serie['genre']); // Enregistre le nouveau description dans la BDD $newSerie->setDescription($serie['description']); // Enregistre le nouveau annee dans la BDD $newSerie->setAnnee($serie['annee']); // Enregistre le nouveau urlImage dans la BDD $newSerie->setUrlImage($serie['urlImage']); // Applique les modifications de BDD $em->persist($newSerie); $em->flush(); } // Lance la view avec le formulaire en paramètre return $this->render('VideoBundle:Sommaire:addSerie.html.twig', array('form' => $form->createView())); }
function list_serie($cb, $empr_list, $nav_bar) { global $serie_list_tmpl; $serie_list_tmpl = str_replace("!!cle!!", $cb, $serie_list_tmpl); $serie_list_tmpl = str_replace("!!list!!", $empr_list, $serie_list_tmpl); $serie_list_tmpl = str_replace("!!nav_bar!!", $nav_bar, $serie_list_tmpl); serie::search_form(); print pmb_bidi($serie_list_tmpl); }
protected function process() { $this->serie = new serie(); if (isset($_POST['codserie'])) { $serie = $this->serie->get($_POST['codserie']); if (!$serie) { $serie = new serie(); $serie->codserie = $_POST['codserie']; } $serie->descripcion = $_POST['descripcion']; $serie->siniva = isset($_POST['siniva']); $serie->irpf = floatval($_POST['irpf']); if ($serie->save()) { $this->new_message("Serie " . $serie->codserie . " guardada correctamente"); } else { $this->new_error_msg("¡Imposible guardar la serie!"); } } else { if (isset($_GET['delete'])) { if (FS_DEMO) { $this->new_error_msg('En el modo demo no puedes eliminar series. Otro usuario podría necesitarlas.'); } else { if (!$this->user->admin) { $this->new_error_msg('Sólo un administrador puede eliminar series.'); } else { $serie = $this->serie->get($_GET['delete']); if ($serie) { if ($serie->delete()) { $this->new_message('Serie eliminada correctamente.'); } else { $this->new_error_msg("¡Imposible eliminar la serie!"); } } else { $this->new_error_msg("Serie no encontrada."); } } } } } }
protected function private_core() { $this->cliente = new cliente(); $this->ejercicio = new ejercicio(); $this->forma_pago = new forma_pago(); $this->proveedor = new proveedor(); $this->regularizacion = new regularizacion_iva(); $serie = new serie(); $this->series = $serie->all(); $this->opciones = array('ventas' => TRUE, 'compras' => TRUE, 'fecha' => 'hoy'); $this->codserie = FALSE; if (isset($_REQUEST['codserie'])) { $this->codserie = $_REQUEST['codserie']; } if (isset($_REQUEST['fecha'])) { $this->opciones['fecha'] = $_REQUEST['fecha']; $this->total = 0; if (isset($_REQUEST['ventas'])) { $albaran_cli = new albaran_cliente(); foreach ($albaran_cli->all_ptefactura(0, 'fecha ASC', $this->codserie) as $alb) { $this->generar_factura_cliente(array($alb)); } $this->new_message($this->total . ' ' . FS_ALBARANES . ' de cliente facturados.'); } else { $this->opciones['ventas'] = FALSE; } $this->total = 0; if (isset($_REQUEST['compras'])) { $albaran_pro = new albaran_proveedor(); foreach ($albaran_pro->all_ptefactura(0, 'fecha ASC', $this->codserie) as $alb) { $this->generar_factura_proveedor(array($alb)); } $this->new_message($this->total . ' ' . FS_ALBARANES . ' de proveedor facturados.'); } else { $this->opciones['compras'] = FALSE; } } }
protected function process() { $this->serie = new serie(); /// ¿El usuario tiene permiso para eliminar en esta página? $this->allow_delete = $this->user->allow_delete_on(__CLASS__); if (isset($_POST['codserie'])) { $serie = $this->serie->get($_POST['codserie']); if (!$serie) { $serie = new serie(); $serie->codserie = $_POST['codserie']; } $serie->descripcion = $_POST['descripcion']; $serie->siniva = isset($_POST['siniva']); $serie->irpf = floatval($_POST['irpf']); if ($serie->save()) { $this->new_message("Serie " . $serie->codserie . " guardada correctamente"); } else { $this->new_error_msg("¡Imposible guardar la serie!"); } } else { if (isset($_GET['delete'])) { if (!$this->user->admin) { $this->new_error_msg('Sólo un administrador puede eliminar series.'); } else { $serie = $this->serie->get($_GET['delete']); if ($serie) { if ($serie->delete()) { $this->new_message('Serie eliminada correctamente.'); } else { $this->new_error_msg("¡Imposible eliminar la serie!"); } } else { $this->new_error_msg("Serie no encontrada."); } } } } }
private function modificar_serie() { $serie = $this->serie->get($_POST['codserie']); if (!$serie) { $serie = new serie(); $serie->codserie = $_POST['codserie']; } $serie->descripcion = $_POST['descripcion']; $serie->siniva = isset($_POST['siniva']); $serie->irpf = floatval($_POST['irpf']); if ($this->num_personalizada) { if ($_POST['codejercicio'] != $serie->codejercicio or $_POST['numfactura'] != $serie->numfactura) { if ($this->user->admin) { if ($this->hay_facturas_venta($serie->codserie)) { $this->new_error_msg('Ya hay facturas con esta serie, no puedes cambiar la numeración inicial.'); } else { $serie->codejercicio = NULL; $serie->numfactura = 1; if ($_POST['codejercicio'] != '') { $serie->codejercicio = $_POST['codejercicio']; $serie->numfactura = intval($_POST['numfactura']); /// anotamos el cambio en el log $fslog = new fs_log(); $fslog->alerta = TRUE; $fslog->detalle = 'Se ha cambiado la numeración inicial de la serie ' . $serie->codserie . ' para el ejercicio ' . $serie->codejercicio . '. Nuevo número inicial: ' . $serie->numfactura; $fslog->ip = $this->user->last_ip; $fslog->usuario = $this->user->nick; $fslog->tipo = 'serie'; $fslog->save(); } } } else { $this->new_error_msg("La numeración de facturas es una cosa delicada," . " solamente un administrador puede hacer cambios.", 'serie', TRUE); } } } if ($serie->save()) { $this->new_message('Datos guardados correctamente.'); } else { $this->new_error_msg("¡Imposible guardar " . FS_SERIE . "!"); } }
private function test_tablas() { $recargar = FALSE; if ($this->informe['offset'] == 0) { /// comprobamos la tabla familias if ($this->db->table_exists('familias')) { $data = $this->db->select("SELECT * FROM familias WHERE madre IS NOT NULL AND madre NOT IN (SELECT codfamilia FROM familias);"); if ($data) { foreach ($data as $d) { $familia = new familia($d); $familia->madre = NULL; $familia->save(); } } } /// comprobamos la tabla de articulos de proveedor if ($this->db->table_exists('articulosprov')) { $this->db->exec("DELETE FROM articulosprov WHERE codproveedor NOT IN (SELECT codproveedor FROM proveedores);"); } $recargar = TRUE; $this->informe['offset'] += 1; } else { if ($this->informe['offset'] == 1) { /// comprobamos la tabla de articulos de proveedor if ($this->db->table_exists('articulosprov')) { $this->db->exec("UPDATE articulosprov SET refproveedor = referencia WHERE refproveedor IS NULL;"); } $recargar = TRUE; $this->informe['offset'] += 1; } else { if ($this->informe['offset'] == 2) { /// comprobamos la tabla de stock if ($this->db->table_exists('stocks')) { $this->db->exec("DELETE FROM stocks s WHERE NOT EXISTS (SELECT referencia FROM articulos a WHERE a.referencia = s.referencia);"); } $recargar = TRUE; $this->informe['offset'] += 1; } else { if ($this->informe['offset'] == 3) { /// comprobamos la tabla de regulaciones de stock if ($this->db->table_exists('lineasregstocks')) { $this->db->exec("DELETE FROM lineasregstocks WHERE idstock NOT IN (SELECT idstock FROM stocks);"); } $recargar = TRUE; $this->informe['offset'] += 1; } else { if ($this->informe['offset'] == 4) { /// comprobamos la tabla de subcuentas de proveedores if ($this->db->table_exists('co_subcuentasprov')) { $this->db->exec("DELETE FROM co_subcuentasprov WHERE codproveedor NOT IN (SELECT codproveedor FROM proveedores);"); } /// comprobamos la tabla de direcciones de proveedores if ($this->db->table_exists('dirproveedores')) { $this->db->exec("DELETE FROM dirproveedores WHERE codproveedor NOT IN (SELECT codproveedor FROM proveedores);"); } /// comprobamos la tabla de subcuentas de clientes if ($this->db->table_exists('co_subcuentascli')) { $this->db->exec("DELETE FROM co_subcuentascli WHERE codcliente NOT IN (SELECT codcliente FROM clientes);"); } /// comprobamos la tabla de direcciones de clientes if ($this->db->table_exists('dirclientes')) { $this->db->exec("DELETE FROM dirclientes WHERE codcliente NOT IN (SELECT codcliente FROM clientes);"); } $recargar = TRUE; $this->informe['offset'] += 1; } else { if ($this->informe['offset'] == 5) { $almacen = new almacen(); if (!$almacen->all()) { $this->db->exec($almacen->install()); } $divisa = new divisa(); if (!$divisa->all()) { $this->db->exec($divisa->install()); } $formap = new forma_pago(); if (!$formap->all()) { $this->db->exec($formap->install()); } $pais = new pais(); if (!$pais->all()) { $this->db->exec($pais->install()); } $serie = new serie(); if (!$serie->all()) { $this->db->exec($serie->install()); } $recargar = TRUE; $this->informe['offset'] += 1; } else { /// comprobamos la tabla de articulos de proveedor if ($this->db->table_exists('articulosprov')) { /// buscamos duplicados $data = $this->db->select("SELECT codproveedor,refproveedor,COUNT(*) as count FROM articulosprov GROUP BY codproveedor,refproveedor HAVING COUNT(*) > 1;"); if ($data) { foreach ($data as $d) { $data2 = $this->db->select("SELECT * FROM articulosprov WHERE codproveedor = '" . $d['codproveedor'] . "' AND refproveedor = '" . $d['refproveedor'] . "';"); if ($data2) { $this->db->exec("DELETE FROM articulosprov WHERE id = " . $this->empresa->var2str($data2[1]['id']) . ";"); } } $recargar = TRUE; $this->informe['offset'] += 1; } } } } } } } } if (!$recargar) { if ($this->informe['all']) { $this->informe['model'] = 'asiento'; } else { $this->informe['model'] = 'fin'; } $this->informe['offset'] = 0; } }
private function test_tablas() { $recargar = FALSE; if ($this->informe['offset'] == 0) { /// comprobamos la tabla familias if ($this->db->table_exists('familias')) { $data = $this->db->select("SELECT * FROM familias WHERE madre IS NOT NULL AND madre NOT IN (SELECT codfamilia FROM familias);"); if ($data) { foreach ($data as $d) { $familia = new familia($d); $familia->madre = NULL; $familia->save(); } } } /// comprobamos la tabla de articulos de proveedor if ($this->db->table_exists('articulosprov')) { $this->db->exec("DELETE FROM articulosprov WHERE codproveedor NOT IN (SELECT codproveedor FROM proveedores);"); } $recargar = TRUE; $this->informe['offset'] += 1; } else { if ($this->informe['offset'] == 1) { /// comprobamos la tabla de articulos de proveedor if ($this->db->table_exists('articulosprov')) { $this->db->exec("UPDATE articulosprov SET refproveedor = referencia WHERE refproveedor IS NULL;"); } $recargar = TRUE; $this->informe['offset'] += 1; } else { if ($this->informe['offset'] == 2) { /// comprobamos la tabla de stock if ($this->db->table_exists('stocks')) { /** * Esta consulta produce un error si no hay datos erroneos, pero da igual */ $this->db->exec("DELETE FROM stocks s WHERE NOT EXISTS " . "(SELECT referencia FROM articulos a WHERE a.referencia = s.referencia);"); } $recargar = TRUE; $this->informe['offset'] += 1; } else { if ($this->informe['offset'] == 3) { /// comprobamos la tabla de regulaciones de stock if ($this->db->table_exists('lineasregstocks')) { $this->db->exec("DELETE FROM lineasregstocks WHERE idstock NOT IN (SELECT idstock FROM stocks);"); } $recargar = TRUE; $this->informe['offset'] += 1; } else { if ($this->informe['offset'] == 4) { /// eliminamos los elementos de contabilidad que apuntan a ejercicios que no existen $tablas = array('co_gruposepigrafes', 'co_epigrafes', 'co_cuentas', 'co_subcuentas'); foreach ($tablas as $tabla) { $this->db->exec("DELETE FROM " . $tabla . " WHERE codejercicio NOT IN (SELECT codejercicio FROM ejercicios);"); } /// comprobamos la tabla de subcuentas de proveedores if ($this->db->table_exists('co_subcuentasprov')) { $this->db->exec("DELETE FROM co_subcuentasprov WHERE codproveedor NOT IN (SELECT codproveedor FROM proveedores);"); } /// comprobamos la tabla de direcciones de proveedores if ($this->db->table_exists('dirproveedores')) { $this->db->exec("DELETE FROM dirproveedores WHERE codproveedor NOT IN (SELECT codproveedor FROM proveedores);"); } /// comprobamos la tabla de subcuentas de clientes if ($this->db->table_exists('co_subcuentascli')) { $this->db->exec("DELETE FROM co_subcuentascli WHERE codcliente NOT IN (SELECT codcliente FROM clientes);"); } /// comprobamos la tabla de direcciones de clientes if ($this->db->table_exists('dirclientes')) { $this->db->exec("DELETE FROM dirclientes WHERE codcliente NOT IN (SELECT codcliente FROM clientes);"); } $recargar = TRUE; $this->informe['offset'] += 1; } else { if ($this->informe['offset'] == 5) { /// comprobamos la tabla de epigrafes if ($this->db->table_exists('co_epigrafes')) { $this->db->exec("UPDATE co_epigrafes SET idgrupo = NULL WHERE idgrupo NOT IN (SELECT idgrupo FROM co_gruposepigrafes);"); } $recargar = TRUE; $this->informe['offset'] += 1; } else { if ($this->informe['offset'] == 6) { $almacen = new almacen(); if (!$almacen->all()) { $this->db->exec($almacen->install()); } $divisa = new divisa(); if (!$divisa->all()) { $this->db->exec($divisa->install()); } $formap = new forma_pago(); if (!$formap->all()) { $this->db->exec($formap->install()); } $pais = new pais(); if (!$pais->all()) { $this->db->exec($pais->install()); } $serie = new serie(); if (!$serie->all()) { $this->db->exec($serie->install()); } $recargar = TRUE; $this->informe['offset'] += 1; } else { /// comprobamos la tabla de articulos de proveedor if ($this->db->table_exists('articulosprov')) { /// buscamos duplicados $data = $this->db->select("SELECT codproveedor,refproveedor,COUNT(*) as count FROM articulosprov GROUP BY codproveedor,refproveedor HAVING COUNT(*) > 1;"); if ($data) { foreach ($data as $d) { $sql = "SELECT * FROM articulosprov WHERE codproveedor = " . $this->empresa->var2str($d['codproveedor']) . " AND refproveedor = " . $this->empresa->var2str($d['refproveedor']) . ";"; $data2 = $this->db->select($sql); if ($data2) { $this->db->exec("DELETE FROM articulosprov WHERE id = " . $this->empresa->var2str($data2[1]['id']) . ";"); } } $recargar = TRUE; $this->informe['offset'] += 1; } } } } } } } } } if (!$recargar) { if ($this->informe['all']) { $this->informe['model'] = 'asiento'; } else { $this->informe['model'] = 'fin'; } $this->informe['offset'] = 0; } }
static function import($title, $statut = 1) { global $dbh; // check sur la variable passée en paramètre if (!$title) { return 0; } // tentative de récupérer l'id associée dans la base (implique que l'autorité existe) // préparation de la requête $key = addslashes($title); $query = "SELECT serie_id FROM series WHERE serie_name='" . rtrim(substr($key, 0, 255)) . "' LIMIT 1 "; $result = @pmb_mysql_query($query, $dbh); if (!$result) { die("can't SELECT series " . $query); } // résultat // récupération du résultat de la recherche $tserie = pmb_mysql_fetch_object($result); // du résultat et récupération éventuelle de l'id if ($tserie->serie_id) { return $tserie->serie_id; } // id non-récupérée, il faut créer la forme. $index = addslashes(strip_empty_words($title)); $query = 'INSERT INTO series SET serie_name="' . $key . '", serie_index=" ' . $index . ' "'; $result = @pmb_mysql_query($query, $dbh); if (!$result) { die("can't INSERT into series" . $query); } $id = pmb_mysql_insert_id($dbh); audit::insert_creation(AUDIT_SERIE, $id); //update authority informations $authority = new authority(0, $id, AUT_TABLE_SERIES); $authority->set_num_statut($statut); $authority->update(); serie::update_index($id); return $id; }
if (stristr($_SERVER['REQUEST_URI'], ".inc.php")) { die("no access"); } require_once "{$class_path}/serie.class.php"; // la taille d'un paquet de notices $lot = SERIE_PAQUET_SIZE; // defini dans ./params.inc.php // taille de la jauge pour affichage $jauge_size = GAUGE_SIZE; // initialisation de la borne de départ if (!isset($start)) { $start = 0; } $v_state = urldecode($v_state); print "<br /><br /><h2 align='center'>" . htmlentities($msg["nettoyage_suppr_series"], ENT_QUOTES, $charset) . "</h2>"; $query = mysql_query("SELECT serie_id from series left join notices on tparent_id=serie_id where tparent_id is null"); $affected = 0; if ($affected = mysql_num_rows($query)) { while ($ligne = mysql_fetch_object($query)) { $serie = new serie($ligne->serie_id); $serie->delete(); } } $query = mysql_query("update notices left join series on tparent_id=serie_id set tparent_id=0 where serie_id is null"); $spec = $spec - CLEAN_SERIES; $v_state .= "<br /><img src=../../images/d.gif hspace=3>" . htmlentities($msg["nettoyage_suppr_series"], ENT_QUOTES, $charset) . " : "; $v_state .= $affected . " " . htmlentities($msg["nettoyage_res_suppr_series"], ENT_QUOTES, $charset); $opt = mysql_query('OPTIMIZE TABLE series'); // mise à jour de l'affichage de la jauge print "<table border='0' align='center' width='{$table_size}' cellpadding='0'><tr><td class='jauge'>\n \t\t\t<img src='../../images/jauge.png' width='{$jauge_size}' height='16'></td></tr></table>\n \t\t\t<div align='center'>100%</div>"; print "\n\t<form class='form-{$current_module}' name='process_state' action='./clean.php' method='post'>\n\t\t<input type='hidden' name='v_state' value=\"{$v_state}\">\n\t\t<input type='hidden' name='spec' value=\"{$spec}\">\n\t</form>\n\t<script type=\"text/javascript\"><!--\n\t\tdocument.forms['process_state'].submit();\n\t\t-->\n\t</script>";
protected function create_notice() { global $pmb_keyword_sep; global $pmb_type_audit; global $webdav_current_user_name, $webdav_current_user_id; $ed_1 = $num_serie = 0; if ($this->data['publisher']) { $ed_1 = editeur::import(array('name' => $this->data['publisher'])); } if ($this->data['serie']) { $num_serie = serie::import($this->data['serie']); } $ind_wew = $this->data['tit1'] . " " . $this->data['tit4']; $ind_sew = \strip_empty_words($ind_wew); $query = "insert into notices set\n\t\t\t\ttit1 = '" . addslashes($this->data['tit1']) . "'," . ($this->data['code'] ? "code='" . $this->data['code'] . "'," : "") . "ed1_id = '" . $ed_1 . "'," . ($this->data['tit4'] ? "tit4 = '" . addslashes($this->data['tit4']) . "'," : "") . ($this->data['npages'] ? "npages = '" . addslashes($this->data['npages']) . "'," : "") . ($this->data['index_l'] ? "index_l = '" . addslashes($this->data['index_l']) . "'," : "") . "\n\t\t\t\tyear = '" . $this->data['year'] . "',\n\t\t\t\ttparent_id = '" . $num_serie . "',\n\t\t\t\tniveau_biblio='m',\n\t\t\t\tniveau_hierar='0',\n\t\t\t\tstatut = '" . $this->config['default_statut'] . "',\n\t\t\t\tindex_wew = '" . $ind_wew . "',\n\t\t\t\tindex_sew = '" . $ind_sew . "',\n\t\t\t\tn_resume = '" . addslashes($this->data['n_resume']) . "',\n\t\t\t\tlien = '" . addslashes($url) . "',\n\t\t\t\tindex_n_resume = '" . \strip_empty_words($this->data['n_resume']) . "'," . ($this->data['thumbnail_content'] ? "thumbnail_url = 'data:image/png;base64," . base64_encode($this->data['thumbnail_content']) . "'," : "") . "create_date = " . ($this->data['create_date'] ? "'" . addslashes($this->data['create_date']) . "'" : "sysdate()") . ",\n\t\t\t\tupdate_date = sysdate()"; pmb_mysql_query($query); format_date($value); $notice_id = pmb_mysql_insert_id(); //traitement audit if ($pmb_type_audit) { $query = "INSERT INTO audit SET "; $query .= "type_obj='1', "; $query .= "object_id='{$notice_id}', "; $query .= "user_id='{$webdav_current_user_id}', "; $query .= "user_name='{$webdav_current_user_name}', "; $query .= "type_modif=1 "; $result = @pmb_mysql_query($query); } if (count($this->data['authors'])) { $i = 0; foreach ($this->data['authors'] as $author) { $aut = array(); if ($author['file-as']) { $infos = explode(",", $author['file-as']); $aut = array('name' => $infos[0], 'rejete' => $infos[1], 'type' => 70); } if (!$aut['name']) { $aut = array('name' => $author['value'], 'type' => 70); } $aut_id = \auteur::import($aut); if ($aut_id) { $query = "insert into responsability set\n\t\t\t\t\t\t\tresponsability_author = '" . $aut_id . "',\n\t\t\t\t\t\t\tresponsability_notice = '" . $notice_id . "',\n\t\t\t\t\t\t\tresponsability_type = '0'"; pmb_mysql_query($query); $i++; } } } if (count($this->data['co_authors'])) { foreach ($this->data['co_authors'] as $author) { $aut = array(); if ($author['file-as']) { $infos = explode(",", $author['file-as']); $aut = array('name' => $infos[0], 'rejete' => $infos[1], 'type' => 70); } if (!$aut['name']) { $aut = array('name' => $author['value'], 'type' => 70); } $aut_id = \auteur::import($aut); if ($aut_id) { $query = "insert into responsability set\n\t\t\t\t\t\t\tresponsability_author = '" . $aut_id . "',\n\t\t\t\t\t\t\tresponsability_notice = '" . $notice_id . "',\n\t\t\t\t\t\t\tresponsability_type = '0',\n\t\t\t\t\t\t\trepsonsability_ordre = '" . $i . "'"; pmb_mysql_query($query); $i++; } } } if (count($this->data['cp'])) { foreach ($this->data['cp'] as $cp_name => $values) { if (is_array($values)) { foreach ($values as $value) { $this->import_cp($notice_id, $cp_name, $value); } } else { $this->import_cp($notice_id, $cp_name, $values); } } } return $notice_id; }
function update($value) { global $dbh; global $msg; global $include_path; global $thesaurus_concepts_active; if (!$value) { return false; } // nettoyage de la chaîne en entrée $value = clean_string($value); $requete = "SET serie_name='" . $value . "', "; $requete .= "serie_index=' " . strip_empty_words($value) . " '"; if ($this->s_id) { // update $requete = 'UPDATE series ' . $requete; $requete .= ' WHERE serie_id=' . $this->s_id . ' LIMIT 1;'; if (pmb_mysql_query($requete, $dbh)) { $rqt_notice = "select notice_id,tit1,tit2,tit3,tit4 from notices where tparent_id=" . $this->s_id; $r_notice = pmb_mysql_query($rqt_notice); while ($r = pmb_mysql_fetch_object($r_notice)) { $rq_serie = "update notices, series set notices.index_serie=serie_index, notices.index_wew=concat(serie_name,' ',tit1,' ',tit2,' ',tit3,' ',tit4),notices.index_sew=concat(' ',serie_index,' ','" . addslashes(strip_empty_words($r->tit1 . " " . $r->tit2 . " " . $r->tit3 . " " . $r->tit4)) . "',' ') where notice_id=" . $r->notice_id . " and serie_id=tparent_id"; pmb_mysql_query($rq_serie); } $aut_link = new aut_link(AUT_TABLE_SERIES, $this->s_id); $aut_link->save_form(); $aut_pperso = new aut_pperso("serie", $this->s_id); $aut_pperso->save_form(); serie::update_index($this->s_id); audit::insert_modif(AUDIT_SERIE, $this->s_id); } else { require_once "{$include_path}/user_error.inc.php"; warning($msg[337], $msg[341]); return FALSE; } } else { // création : s'assurer que le titre n'existe pas déjà $dummy = "SELECT * FROM series WHERE serie_name REGEXP '^{$value}\$' LIMIT 1 "; $check = pmb_mysql_query($dummy, $dbh); if (pmb_mysql_num_rows($check)) { require_once "{$include_path}/user_error.inc.php"; warning($msg[336], $msg[340]); return FALSE; } $requete = 'INSERT INTO series ' . $requete . ';'; if (pmb_mysql_query($requete, $dbh)) { $this->s_id = pmb_mysql_insert_id(); $aut_link = new aut_link(AUT_TABLE_SERIES, $this->s_id); $aut_link->save_form(); $aut_pperso = new aut_pperso("serie", $this->s_id); $aut_pperso->save_form(); audit::insert_creation(AUDIT_SERIE, $this->s_id); } else { require_once "{$include_path}/user_error.inc.php"; warning($msg[336], $msg[342]); return FALSE; } } // Indexation concepts if ($thesaurus_concepts_active == 1) { $index_concept = new index_concept($this->s_id, TYPE_SERIE); $index_concept->save(); } // Mise à jour des vedettes composées contenant cette autorité vedette_composee::update_vedettes_built_with_element($this->s_id, "serie"); return TRUE; }
// maj de index_serie $index_serie=strip_empty_words($serie_nom); $rqt = "update notices set index_serie='".$index_serie."' where tparent_id='".$id."' "; mysql_query($rqt, $dbh) ; */ include './autorites/series/series_list.inc.php'; break; case 'serie_form': // création / modification d'un titre if (!$id) { // affichage du form pour création $serie = new serie(0); $serie->show_form(); } else { // affichage du form pour modification $serie = new serie($id); $serie->show_form($id); } break; case 'serie_last': $last_param = 1; $tri_param = "order by serie_id desc "; $limit_param = "limit 0, {$pmb_nb_lastautorities} "; $clef = ""; $nbr_lignes = 0; include './autorites/series/series_list.inc.php'; break; default: // affichage du début de la liste (par défaut) include './autorites/series/series_list.inc.php'; break;
function update_in_database($id_notice = 0) { global $dbh; global $pmb_synchro_rdf; $new_notice = 2; $notice_retour = $id_notice; if (!$id_notice) { $retour = array(2, 0); return $retour; } //synchro_rdf if ($pmb_synchro_rdf) { $synchro_rdf = new synchro_rdf(); $synchro_rdf->delRdf($notice_retour, 0); } // traitement des titres uniformes global $pmb_use_uniform_title; if ($pmb_use_uniform_title) { if (count($this->titres_uniformes)) { $ntu = new tu_notice($id_notice); $ntu->update($this->titres_uniformes); } } for ($i = 0; $i < 2; $i++) { if ($this->editors[$i]['id']) { $editor_ids[$i] = $this->editors[$i]['id']; } else { $editor_ids[$i] = editeur::import($this->editors[$i]); } } if ($this->collection["id"]) { $collection_id = $this->collection["id"]; } else { $this->collection['parent'] = $editor_ids[0]; $collection_id = collection::import($this->collection); } if ($this->subcollection["id"]) { $subcollection_id = $this->subcollection["id"]; } else { $this->subcollection['coll_parent'] = $collection_id; $subcollection_id = subcollection::import($this->subcollection); $serie_id = serie::import(stripslashes($this->serie)); } /* traitement de Dewey */ if (!$this->internal_index) { if (!$this->dewey["new_comment"]) { $this->dewey["new_comment"] = ""; } if (!$this->dewey["new_pclass"]) { $this->dewey["new_pclass"] = ""; } $this->internal_index = indexint::import(clean_string($this->dewey[0]), clean_string($this->dewey["new_comment"]), clean_string($this->dewey["new_pclass"])); } $date_parution_z3950 = notice::get_date_parution($this->year); /* Origine de la notice */ $this->orinot_id = origine_notice::import($this->origine_notice); if ($this->orinot_id == 0) { $this->orinot_id = 1; } $sql_ins = "update notices set\n\t\t\ttypdoc \t='" . $this->document_type . "',\n\t\t\tcode \t ='" . $this->isbn . "',\t \n\t\t\ttit1 ='" . $this->titles[0] . "', \n\t\t\ttit2 ='" . $this->titles[1] . "', \n\t\t\ttit3 ='" . $this->titles[2] . "', \n\t\t\ttit4 ='" . $this->titles[3] . "', \n\t\t\ttparent_id ='" . $serie_id . "', \n\t\t\ttnvol ='" . $this->nbr_in_serie . "', \n\t\t\ted1_id =" . $editor_ids[0] . " , \n\t\t\ted2_id =" . $editor_ids[1] . " , \n\t\t\tyear ='" . $this->year . "', \n\t\t\tnpages ='" . $this->page_nbr . "', \n\t\t\till ='" . $this->illustration . "', \n\t\t\tsize ='" . $this->size . "', \n\t\t\taccomp ='" . $this->accompagnement . "', \n\t\t\tcoll_id =" . $collection_id . " , \n\t\t\tsubcoll_id =" . $subcollection_id . " , \n\t\t\tnocoll ='" . $this->nbr_in_collection . "', \n\t\t\tmention_edition ='" . $this->mention_edition . "', \n\t\t\tn_gen ='" . $this->general_note . "', \n\t\t\tn_contenu ='" . $this->content_note . "', \n\t\t\tn_resume ='" . $this->abstract_note . "', \n\t\t\tindexint ='" . $this->internal_index . "', \n\t\t\tstatut\t\t\t\t\t='" . $this->statut . "',\n\t\t\tcommentaire_gestion\t\t='" . $this->commentaire_gestion . "',\n\t\t\tindexation_lang\t\t\t='" . $this->indexation_lang . "',\n\t\t\tthumbnail_url\t\t\t='" . $this->thumbnail_url . "',\n\t\t\tindex_l ='" . clean_tags($this->free_index) . "', \n\t\t\tniveau_biblio ='" . $this->bibliographic_level . "', \n\t\t\tniveau_hierar ='" . $this->hierarchic_level . "', \n\t\t\tlien ='" . $this->link_url . "', \n\t\t\teformat ='" . $this->link_format . "', \n\t\t\torigine_catalogage ='" . $this->orinot_id . "', \n\t\t\tprix ='" . $this->prix . "',\n\t\t\tdate_parution \t\t\t='" . $date_parution_z3950 . "' \n\t\t\twhere notice_id='{$id_notice}' "; //echo "<pre>"; //print_r($this->aut_array); //echo "</pre>"; //echo $sql_ins."<br />"; //echo "<pre>"; //print_r($this->categories); //echo "</pre>"; //exit; $sql_result_ins = pmb_mysql_query($sql_ins) or die("Couldn't update notices : " . $sql_ins); $notice_retour = $id_notice; audit::insert_modif(AUDIT_NOTICE, $id_notice); // purge de la base des responsabilités de la notice intégrée... if ($notice_retour) { $rqt_del = "delete from responsability where responsability_notice='{$notice_retour}'"; $sql_result_del = pmb_mysql_query($rqt_del) or die("Couldn't purge table responsability : " . $rqt_del); } $rqt_ins = "insert into responsability (responsability_author, responsability_notice, responsability_fonction, responsability_type, responsability_ordre) VALUES "; for ($i = 0; $i < sizeof($this->aut_array); $i++) { $aut['id'] = clean_string($this->aut_array[$i]['id']); $aut['name'] = clean_string($this->aut_array[$i]['entree']); $aut['rejete'] = clean_string($this->aut_array[$i]['rejete']); $aut['date'] = clean_string($this->aut_array[$i]['date']); $aut['type'] = $this->aut_array[$i]['type_auteur']; $aut['subdivision'] = clean_string($this->aut_array[$i]['subdivision']); $aut['numero'] = clean_string($this->aut_array[$i]['numero']); $aut['lieu'] = clean_string($this->aut_array[$i]['lieu']); $aut['ville'] = clean_string($this->aut_array[$i]['ville']); $aut['pays'] = clean_string($this->aut_array[$i]['pays']); $aut['web'] = clean_string($this->aut_array[$i]['web']); $aut['author_comment'] = clean_string($this->aut_array[$i]['author_comment']); $aut['authority_number'] = clean_string($this->aut_array[$i]['authority_number']); /* Origine de l'autorité : on reprend les infos d'origine de la notice pour les attribuées aux origines des autorités */ $id_origine_auth = 0; $id_origine_auth = origin_authorities::import($this->origine_notice); if ($id_origine_auth == 0) { $id_origine_auth = 1; } // import de l'autorité auteur si elle n'existe pas et conservation des infos sur l'origine de l'autorité if ($aut['authority_number'] != '' && $id_origine_auth) { $this->aut_array[$i]["id"] = $this->insert_authority_infos($aut['authority_number'], "author", $id_origine_auth, $aut); } if (!$this->aut_array[$i]["id"]) { $this->aut_array[$i]["id"] = auteur::import($aut); } if ($this->aut_array[$i]["id"]) { $rqt = $rqt_ins . " (" . $this->aut_array[$i]["id"] . "," . $notice_retour . ",'" . $this->aut_array[$i]['fonction'] . "'," . $this->aut_array[$i]['responsabilite'] . "," . $i . ") "; $res_ins = pmb_mysql_query($rqt, $dbh); } } // traitement des categories if ($this->categorisation_type == "categorisation_auto") { traite_categories_enreg($notice_retour, $this->categories); } else { $rqt_del = "delete from notices_categories where notcateg_notice='{$notice_retour}' "; $res_del = @pmb_mysql_query($rqt_del, $dbh); $rqt_ins = "insert into notices_categories (notcateg_notice, num_noeud, ordre_categorie) VALUES "; $rqt_ins_values = array(); foreach ($this->categories as $i => $category) { $id_categ = $category['categ_id']; if ($id_categ) { $rqt_ins_values[] = " ('{$notice_retour}','{$id_categ}', {$i}) "; } } $rqt_ins .= implode(",", $rqt_ins_values); $res_ins = @pmb_mysql_query($rqt_ins, $dbh); } // traitement des langues // langues de la publication $rqt_del = "delete from notices_langues where num_notice='{$notice_retour}' "; $res_del = pmb_mysql_query($rqt_del, $dbh); if (is_array($this->language_code) && count($this->language_code)) { $rqt_ins = "insert into notices_langues (num_notice, type_langue, code_langue, ordre_langue) VALUES "; foreach ($this->language_code as $ordre_lang => $code_lang) { if ($code_lang) { $rqt = $rqt_ins . " ('{$notice_retour}',0, '{$code_lang}', {$ordre_lang}) "; $res_ins = @pmb_mysql_query($rqt, $dbh); } } } // langues originales if (is_array($this->original_language_code) && count($this->original_language_code)) { $rqt_ins = "insert into notices_langues (num_notice, type_langue, code_langue, ordre_langue) VALUES "; foreach ($this->original_language_code as $ordre_lang => $code_lang) { if ($code_lang) { $rqt = $rqt_ins . " ('{$notice_retour}',1, '{$code_lang}', {$ordre_lang}) "; $res_ins = @pmb_mysql_query($rqt, $dbh); } } } //Traitement des champs personnalisés (du formulaire !!!) $p_perso = new parametres_perso("notices"); $nberrors = $p_perso->check_submited_fields(); $p_perso->rec_fields_perso($notice_retour); //Traitement import perso global $notice_id, $notice_org, $notice_type_org; if (function_exists('z_recup_noticeunimarc_suite') && function_exists('recup_noticeunimarc_suite')) { //Suppression des champs persos $requete = "delete from notices_custom_values where notices_custom_origine=" . $notice_retour; @pmb_mysql_query($requete); $notice_id = $notice_retour; z_recup_noticeunimarc_suite($notice_org); z_import_new_notice_suite(); } // Mise à jour des index de la notice notice::majNotices($notice_retour); // Mise à jour de la table notices_global_index notice::majNoticesGlobalIndex($notice_retour); // Mise à jour de la table notices_mots_global_index notice::majNoticesMotsGlobalIndex($notice_retour); //Documents numériques foreach ($this->doc_nums as $doc_num) { if (!$doc_num["a"]) { continue; } explnum_add_from_url($notice_retour, $this->bull_id, $doc_num["b"], $doc_num["a"], false, $this->source_id, $doc_num["f"], '', $doc_num["s"]); } //synchro_rdf if ($pmb_synchro_rdf) { $synchro_rdf->addRdf($notice_retour, 0); } $retour = array($new_notice, $notice_retour); return $retour; }
public function check() { $eje = new ejercicio(); $serie = new serie(); foreach ($eje->all() as $e) { $secs = $this->all_from_ejercicio($e->codejercicio); foreach ($serie->all() as $serie) { $encontrada = FALSE; foreach ($secs as $s) { if ($s->codserie == $serie->codserie) { $encontrada = TRUE; } } if (!$encontrada) { $aux = new secuencia_ejercicio(); $aux->codejercicio = $e->codejercicio; $aux->codserie = $serie->codserie; if (!$aux->save()) { $this->new_error_msg("¡Imposible crear la secuencia para el ejercicio " . $aux->codejercicio . " y la serie " . $aux->codserie . "!"); } } } } }
public function new_codigo() { $num = intval(FS_NFACTURA_CLI); /// definido en el config2 // buscamos el número inicial para la serie $serie0 = new serie(); if ($serie = $serie0->get($this->codserie)) { if ($this->codejercicio == $serie->codejercicio) { $num = $serie->numfactura; } } /// buscamos un hueco $encontrado = FALSE; $fecha = $this->fecha; $numeros = $this->db->select("SELECT " . $this->db->sql_to_int('numero') . " as numero,fecha\n FROM " . $this->table_name . " WHERE codejercicio = " . $this->var2str($this->codejercicio) . " AND codserie = " . $this->var2str($this->codserie) . " ORDER BY numero ASC;"); if ($numeros) { foreach ($numeros as $n) { if (intval($n['numero']) > $num) { $encontrado = TRUE; $fecha = Date('d-m-Y', strtotime($n['fecha'])); break; } else { $num++; } } } if ($encontrado) { $this->numero = $num; $this->fecha = $fecha; } else { $this->numero = $num; /// nos guardamos la secuencia para abanq/eneboo $sec = new secuencia(); $sec = $sec->get_by_params2($this->codejercicio, $this->codserie, 'nfacturacli'); if ($sec) { if ($sec->valorout <= $this->numero) { $sec->valorout = 1 + $this->numero; $sec->save(); } } } if (FS_NEW_CODIGO == 'eneboo') { $this->codigo = $this->codejercicio . sprintf('%02s', $this->codserie) . sprintf('%06s', $this->numero); } else { $this->codigo = 'FAC' . $this->codejercicio . $this->codserie . $this->numero; } }
function import_new_notice() { global $dbh; global $notice_id; global $bulletin_ex; //Identifiant du bulletin $bulletin_ex = 0; global $id_unimarc; global $notices_crees; global $bulletins_crees; global $notices_a_creer; global $bulletins_a_creer; global $base_path; global $pmb_keyword_sep; global $link_generate; global $doc_type; global $hierarchic_level; global $bibliographic_level; global $isbn_OK; global $prix; global $prix_cd; global $cb; global $tit_200a; global $tit_200c; global $tit_200d; global $tit_200e; global $tit_200v; global $serie_200; global $editor; global $editeur_lieu; global $editeur_adr; global $editeur_nom; global $editeur_date; global $editeur_pays; global $editeur_pmbfields; global $no_edition; global $npages; global $ill; global $size; global $accomp; global $collection_225; global $n_contenu; global $n_resume; global $n_gen; global $EAN; global $collection_410; global $collection_411; global $tu_500; global $tu_500_r; global $tu_500_s; global $tu_500_j; global $serie; global $index_sujets; global $dewey; global $dewey_l; global $aut_700; global $aut_701; global $aut_702; global $aut_710; global $aut_711; global $aut_712; global $origine_notice; global $lien; global $eformat; global $analytique; global $statutnot; global $indicateur; global $add_explnum; global $info_686; global $authorities_notices; global $authorities_default_origin; $origin_authority = $authorities_default_origin; $add_explnum = FALSE; /* traitement des éditeurs */ $coll_id = 0; $subcoll_id = 0; $serie_id = 0; $tnvol_ins = ""; $ed1_id = 0; $ed2_id = 0; $year = ""; $date_parution = "0000-00-00"; //On récupère le tableau des notices créées à partir du fichier temporaire (rechargement d'iframe) if ($link_generate && !isset($notices_crees)) { $tabimport_id = file_get_contents("{$base_path}/temp/liste_id" . SESSid . ".txt"); if ($tabimport_id) { $tabimport_id = unserialize($tabimport_id); $notices_crees = $tabimport_id['notices_existantes']; $notices_a_creer = $tabimport_id['notices_a_creer']; $bulletins_crees = $tabimport_id['bulletins_crees']; $bulletins_a_creer = $tabimport_id['bulletins_a_creer']; } } if (!is_array($notices_crees)) { $notices_crees = array(); } //Pour le cas ou on est sur une notice (bidon) d'article juste pour les exemplaires de bulletin if ($bibliographic_level == "a" && $tit_200d[0] == "Article_expl_bulletin") { //On importe rien return; } elseif ($tit_200d[0] == "Article_expl_bulletin") { //Pour le cas ou on import sans les liens un fichier exporter avec les exemplaires et les liens $tit_200d[0] = ""; } if ($bibliographic_level != "a" && $bibliographic_level != "b") { //Pour les articles et les bulletins on ne garde pas les informations suivantes $year = clean_string($editeur_date[0]); $date_parution = notice::get_date_parution($year); //traitement des éditeurs $editor = array(); foreach ($editeur_nom as $key_nom1 => $nom1) { foreach ($nom1 as $key_nom2 => $nom2) { $mon_ed = array(); $mon_ed["c"] = $nom2; if ($editeur_adr[$key_nom1][$key_nom2]) { $mon_ed["b"] = $editeur_adr[$key_nom1][$key_nom2]; } if ($editeur_lieu[$key_nom1][$key_nom2]) { $mon_ed["a"] = $editeur_lieu[$key_nom1][$key_nom2]; } if ($editeur_pays[$key_nom1][$key_nom2]) { $mon_ed["z"] = $editeur_pays[$key_nom1][$key_nom2]; } if ($editeur_pmbfields[$key_nom1][$key_nom2]) { //Si j'ai ces informations c'est un export PMB donc je n'ai pas deux editeurs dans le même 210 foreach ($editeur_pmbfields[$key_nom1] as $val9) { if (preg_match("/^(.+?):(.+)\$/", $val9, $matches)) { $mon_ed[trim($matches[1])] = $matches[2]; } } } $editor[] = $mon_ed; } } $ed = array(); $ed['name'] = clean_string($editor[0]['c']); $ed['adr'] = clean_string($editor[0]['b']); if ($editor[0]['adr1']) { $ed['adr'] = clean_string($editor[0]['adr1']); } //Si cela vient de PMB dans $b j'ai un concat $ed['ville'] = clean_string($editor[0]['a']); $ed['adr2'] = clean_string($editor[0]['adr2']); $ed['cp'] = clean_string($editor[0]['cp']); $ed['pays'] = clean_string($editor[0]['z']); $ed['web'] = clean_string($editor[0]['web']); $ed['ed_comment'] = clean_string($editor[0]['comment']); $ed1_id = editeur::import($ed); $ed = array(); $ed['name'] = clean_string($editor[1]['c']); $ed['adr'] = clean_string($editor[1]['b']); if ($editor[1]['adr1']) { $ed['adr'] = clean_string($editor[1]['adr1']); } //Si cela vient de PMB dans $b j'ai un concat $ed['ville'] = clean_string($editor[1]['a']); $ed['adr2'] = clean_string($editor[1]['adr2']); $ed['cp'] = clean_string($editor[1]['cp']); $ed['pays'] = clean_string($editor[1]['z']); $ed['web'] = clean_string($editor[1]['web']); $ed['ed_comment'] = clean_string($editor[1]['comment']); $ed2_id = editeur::import($ed); if ($bibliographic_level != "s") { //Pour les periodiques on ne garde pas les informations suivantes /* traitement des collections */ $coll_name = ""; $subcoll_name = ""; $coll_issn = ""; $subcoll_issn = ""; $nocoll_ins = ""; /* traitement de 225$a, si rien alors 410$t pour la collection */ if ($collection_225[0]['a'] != "") { $coll_name = $collection_225[0]['a']; $coll_issn = $collection_225[0]['x']; } elseif ($collection_410[0]['t'] != "") { $coll_name = $collection_410[0]['t']; $coll_issn = $collection_410[0]['x']; $coll_aut_number = $collection_410[0]['3']; } /* traitement de 225$i, si rien alors 411$t pour la sous-collection */ if ($collection_225[0]['i'] != "") { $subcoll_name = $collection_225[0]['i']; $subcoll_issn = $collection_225[1]['x']; } elseif ($collection_411[0]['t'] != "") { $subcoll_name = $collection_411[0]['t']; $subcoll_issn = $collection_411[0]['x']; $coll_aut_number = $collection_411[0]['3']; } /* gaffe au nocoll, en principe en 225$v selon FL sinon en 410$v ou 411$v*/ if ($collection_225[0]['v'] != "") { $nocoll_ins = $collection_225[0]['v']; } elseif ($collection_410[0]['v'] != "") { $nocoll_ins = $collection_410[0]['v']; } elseif ($collection_411[0]['v'] != "") { $nocoll_ins = $collection_411[0]['v']; } else { $nocoll_ins = ""; } $collec['name'] = clean_string($coll_name); $collec['parent'] = $ed1_id; $collec['issn'] = clean_string($coll_issn); $collec['authority_number'] = $coll_aut_number; if ($collec['authority_number']) { $coll_id = keep_authority_infos($collec['authority_number'], "collection", $origin_authority, 0, $collec); } else { $coll_id = collection::import($collec); } /* sous collection */ $subcollec['name'] = clean_string($subcoll_name); $subcollec['coll_parent'] = $coll_id; $subcollec['issn'] = clean_string($subcoll_issn); $subcollec['authority_number'] = $subcoll_aut_number; if ($subcollec['authority_number']) { $subcoll_id = keep_authority_infos($subcollec['authority_number'], "subcollection", $origin_authority, 0, $subcollec); } else { $subcoll_id = collection::import($subcollec); } $subcoll_id = subcollection::import($subcollec); /* traitement des séries */ $serie_id = serie::import(clean_string($serie[0]['t'])); $tnvol_ins = $serie[0]['v']; if (!$serie_id) { $serie_id = serie::import(clean_string($serie_200[0]['i'])); $serie[0]['t'] = $serie_200[0]['i']; //$tnvol_ins=$serie_200[0]['h']; } if (!$tnvol_ins) { $tnvol_ins = $serie_200[0]['h']; } } } /* traitement de Dewey */ $indexint_id = indexint::import(clean_string($dewey[0]), $dewey_l[0]); if (!$indexint_id and count($info_686)) { $indexint_id = indexint::import(clean_string($info_686[0]["a"]), $info_686[0]["l"], 99); } /* Traitement des notes */ $n_resume_total = ""; $n_gen_total = ""; $n_contenu_total = ""; if (!$n_resume) { $n_resume = array(); } $n_resume_total = implode("\n", $n_resume); if (!$n_gen) { $n_gen = array(); } $n_gen_total = implode("\n", $n_gen); if (!$n_contenu) { $n_contenu = array(); } $n_contenu_total = implode("\n", $n_contenu); // ajout : les 464$a sont ajouté aux notes de contenu à déporter éventuellement dans func_bdp41 si besoin for ($i = 0; $i < count($analytique); $i++) { $ana = array(); for ($j = 0; $j < count($analytique[$i]); $j++) { $ana[$analytique[$i][$j]["label"]][] = $analytique[$i][$j]["content"]; } if (count($ana["a"]) == 1) { //Selon la norme le $a n'est pas répétable dans le même champ 4XX $n_contenu_total .= $ana["a"][0] . (count($ana["e"]) ? " ; " . implode(" ; ", $ana["e"]) : "") . (count($ana["f"]) ? " / " . implode(" / ", $ana["f"]) : "") . (count($ana["g"]) ? " / " . implode(" / ", $ana["g"]) : "") . "\n"; } else { //Au cas où for ($j = 0; $j < count($ana["a"]); $j++) { $n_contenu_total .= $ana["a"][$j] . ($ana["e"][$j] ? " ; " . $ana["e"][$j] : "") . ($ana["f"][$j] ? " / " . $ana["f"][$j] : "") . ($ana["g"][$j] ? " / " . $ana["g"][$j] : "") . "\n"; } } } // Préparation des titres $tit[0]['a'] = implode(" ; ", $tit_200a); if ($bibliographic_level != "a" && $bibliographic_level != "b" && $bibliographic_level != "s") { //Pour les articles et les bulletins on ne garde pas les informations suivantes $tit[0]['c'] = implode(" ; ", $tit_200c); } else { $tit[0]['c'] = ""; } $tit[0]['d'] = implode(" ; ", $tit_200d); $tit[0]['e'] = implode(" ; ", $tit_200e); if (is_array($index_sujets)) { $index_l = implode(' ' . $pmb_keyword_sep . ' ', $index_sujets); } else { $index_l = $index_sujets; } // if (trim($n_resume_total)=="") $n_resume_total = $n_gen_total." ".$n_contenu_total ; /* Origine de la notice */ $origine_not['nom'] = clean_string($origine_notice[0]['b']); $origine_not['pays'] = clean_string($origine_notice[0]['a']); $orinot_id = origine_notice::import($origine_not); if ($orinot_id == 0) { $orinot_id = 1; } if ($bibliographic_level != "a" && $bibliographic_level != "s") { //Pour les articles et les periodiques on ne garde pas les informations suivantes // prix $price = $prix[0]; //Pour les CDs if (!$price) { $price = $prix_cd[0]; } $illustration = implode(" : ", $ill); $taille = implode(" ; ", $size); $mat_accomp = implode(" + ", $accomp); if ($bibliographic_level != "b") { $mention_edit = implode(", ", $no_edition); } else { $mention_edit = ""; } } else { $illustration = ""; $taille = ""; $mat_accomp = ""; } if ($bibliographic_level != "s") { //Pour les periodiques on ne garde pas les informations suivantes $nbpages = implode(" - ", $npages); } else { $nbpages = ""; } /* and at least, the insertion in notices table */ $sql_ins = "insert into notices (\n\t\t\t\t\t\ttypdoc\t\t\t,\n\t\t\t\t\t\tcode \t,\n\t\t\t\t\t\tstatut\t\t\t,\n\t\t tit1 ,\n\t\t tit2 ,\n\t\t tit3 ,\n\t\t tit4 ,\n\t\t tparent_id ,\n\t\t tnvol ,\n\t\t ed1_id ,\n\t\t ed2_id ,\n\t\t year ,\n\t\t npages ,\n\t\t ill ,\n\t\t size ,\n\t\t accomp ,\n\t\t coll_id ,\n\t\t subcoll_id ,\n\t\t nocoll ,\n\t\t mention_edition\t,\n\t\t n_gen ,\n\t\t n_contenu ,\n\t\t n_resume ,\n\t\t index_l,\n\t\t indexint,\n\t\t niveau_biblio,\n\t\t niveau_hierar,\n\t\t lien,\n\t\t eformat,\n\t\t origine_catalogage,\n\t\t prix,\n\t\t\t\t\t\tcreate_date,\n\t\t\t\t\t\tdate_parution\n\t\t\t\t) values (\n\t\t\t\t\t\t'" . $doc_type . "',\t\n\t\t\t\t\t\t'" . addslashes($isbn_OK) . "',\t\n\t\t\t\t\t\t'" . $statutnot . "',\n\t\t '" . addslashes(clean_string($tit[0]['a'])) . "',\n\t\t '" . addslashes(clean_string($tit[0]['c'])) . "',\n\t\t '" . addslashes(clean_string($tit[0]['d'])) . "',\n\t\t '" . addslashes(clean_string($tit[0]['e'])) . "',\n\t\t '" . $serie_id . "',\n\t\t '" . addslashes($tnvol_ins) . "',\n\t\t " . $ed1_id . " ,\n\t\t " . $ed2_id . " ,\n\t\t '" . addslashes($year) . "',\n\t\t '" . addslashes($nbpages) . "',\n\t\t '" . addslashes($illustration) . "',\n\t\t '" . addslashes($taille) . "',\n\t\t '" . addslashes($mat_accomp) . "',\n\t\t " . $coll_id . " ,\n\t\t " . $subcoll_id . " ,\n\t\t '" . addslashes($nocoll_ins) . "',\n\t\t '" . addslashes($mention_edit) . "',\n\t\t '" . addslashes($n_gen_total) . "',\n\t\t \t'" . addslashes($n_contenu_total) . "',\n\t\t \t'" . addslashes($n_resume_total) . "',\n\t\t '" . addslashes($index_l) . "',\n\t\t '" . $indexint_id . "',\n\t\t '" . $bibliographic_level . "',\n\t\t '" . $hierarchic_level . "',\n\t\t '" . addslashes($lien[0]) . "',\n\t\t '" . addslashes($eformat[0]) . "',\n\t\t '" . $orinot_id . "',\n\t\t '" . addslashes($price) . "',\n\t\t\t\t\t\tsysdate(),\n\t\t\t\t\t\t'" . addslashes($date_parution) . "'\n\t\t\t\t\t\t)"; mysql_query($sql_ins, $dbh) or die("Couldn't insert into notices ! = " . $sql_ins); $notice_id = mysql_insert_id($dbh); notice::majNotices($notice_id); audit::insert_creation(AUDIT_NOTICE, $notice_id); //calcul des droits d'accès s'ils sont activés calc_notice_acces_rights($notice_id); // on devait attendre que la notice soit intégrée pour faire l'association avec la notice..; if ($collec['authority_number']) { keep_authority_infos($collec['authority_number'], "scollection", $origin_authority, $notice_id, $collec); } if ($subcollec['authority_number']) { keep_authority_infos($subcollec['authority_number'], "subcollection", $origin_authority, $notice_id, $subcollec); } /* INSERT de la notice OK, on va traiter les auteurs 70# : personnal : type auteur 70 71# : collectivités : type auteur 71 1 seul en 700 idem pour les déclinaisons n en 701 n en 702 les 7#0 tombent en auteur principal : responsability_type = 0 les 7#1 tombent en autre auteur : responsability_type = 1 les 7#2 tombent en auteur secondaire : responsability_type = 2 */ $aut_array = array(); /* on compte tout de suite le nbre d'enreg dans les répétables */ $nb_repet_701 = sizeof($aut_701); $nb_repet_711 = sizeof($aut_711); $nb_repet_702 = sizeof($aut_702); $nb_repet_712 = sizeof($aut_712); //indicateur["710"]; /* renseignement de aut0 */ if ($aut_700[0][a] != "") { /* auteur principal en 700 ? */ $aut_array[] = array("entree" => $aut_700[0]['a'], "rejete" => $aut_700[0]['b'], "author_comment" => $aut_700[0]['c'] . " " . $aut_700[0]['d'], "date" => $aut_700[0]['f'], "type_auteur" => "70", "fonction" => $aut_700[0][4], "id" => 0, "responsabilite" => 0, "ordre" => 0, 'authority_number' => $aut_700[0][3]); } elseif ($aut_710[0]['a'] != "") { /* auteur principal en 710 ? */ if (substr($indicateur["710"][0], 0, 1) == "1") { $type_auteur = "72"; } else { $type_auteur = "71"; } $lieu = $aut_710[0]['e']; if (!$lieu) { $lieu = $aut_710[0]['k']; } $aut_array[] = array("entree" => $aut_710[0]['a'], "rejete" => $aut_710[0]['g'], "subdivision" => $aut_710[0]['b'], "author_comment" => $aut_710[0]['c'], "numero" => $aut_710[0]['d'], "lieu" => $lieu, "ville" => $aut_710[0]['l'], "pays" => $aut_710[0]['m'], "web" => $aut_710[0]['n'], "date" => $aut_710[0]['f'], "type_auteur" => $type_auteur, "fonction" => $aut_710[0][4], "id" => 0, "responsabilite" => 0, "ordre" => 0, 'authority_number' => $aut_710[0][3]); } /* renseignement de aut1 */ for ($i = 0; $i < $nb_repet_701; $i++) { $aut_array[] = array("entree" => $aut_701[$i]['a'], "rejete" => $aut_701[$i]['b'], "author_comment" => $aut_701[$i]['c'] . " " . $aut_701[$i]['d'], "date" => $aut_701[$i]['f'], "type_auteur" => "70", "fonction" => $aut_701[$i][4], "id" => 0, "responsabilite" => 1, "ordre" => $i + 1, 'authority_number' => $aut_701[$i][3]); } for ($i = 0; $i < $nb_repet_711; $i++) { if (substr($indicateur["711"][$i], 0, 1) == "1") { $type_auteur = "72"; } else { $type_auteur = "71"; } $lieu = $aut_711[$i]['e']; if (!$lieu) { $lieu = $aut_711[$i]['k']; } $aut_array[] = array("entree" => $aut_711[$i]['a'], "rejete" => $aut_711[$i]['g'], "subdivision" => $aut_711[$i]['b'], "author_comment" => $aut_711[$i]['c'], "numero" => $aut_711[$i]['d'], "lieu" => $lieu, "ville" => $aut_711[$i]['l'], "pays" => $aut_711[$i]['m'], "web" => $aut_711[$i]['n'], "date" => $aut_711[$i]['f'], "type_auteur" => $type_auteur, "fonction" => $aut_711[$i][4], "id" => 0, "responsabilite" => 1, "ordre" => $i + 1, 'authority_number' => $aut_711[$i][3]); } /* renseignement de aut2 */ for ($i = 0; $i < $nb_repet_702; $i++) { $aut_array[] = array("entree" => $aut_702[$i]['a'], "rejete" => $aut_702[$i]['b'], "author_comment" => $aut_702[$i]['c'] . " " . $aut_702[$i]['d'], "date" => $aut_702[$i]['f'], "type_auteur" => "70", "fonction" => $aut_702[$i][4], "id" => 0, "responsabilite" => 2, "ordre" => $i + 1, 'authority_number' => $aut_702[$i][3]); } for ($i = 0; $i < $nb_repet_712; $i++) { if (substr($indicateur["712"][$i], 0, 1) == "1") { $type_auteur = "72"; } else { $type_auteur = "71"; } $lieu = $aut_712[$i]['e']; if (!$lieu) { $lieu = $aut_712[$i]['k']; } $aut_array[] = array("entree" => $aut_712[$i]['a'], "rejete" => $aut_712[$i]['g'], "subdivision" => $aut_712[$i]['b'], "author_comment" => $aut_712[$i]['c'], "numero" => $aut_712[$i]['d'], "lieu" => $lieu, "ville" => $aut_712[$i]['l'], "pays" => $aut_712[$i]['m'], "web" => $aut_712[$i]['n'], "date" => $aut_712[$i]['f'], "type_auteur" => $type_auteur, "fonction" => $aut_712[$i][4], "id" => 0, "responsabilite" => 2, "ordre" => $i + 1, 'authority_number' => $aut_712[$i][3]); } // récup des infos auteurs et mise en tableau : // appel de la fonction membre d'importation et insertion en table $rqt_ins = "insert into responsability (responsability_author, responsability_notice, responsability_fonction, responsability_type, responsability_ordre) VALUES "; $values = ""; if (count($aut_array)) { for ($i = 0; $i < sizeof($aut_array); $i++) { $aut = array(); $aut['name'] = clean_string($aut_array[$i]['entree']); $aut['rejete'] = clean_string($aut_array[$i]['rejete']); $aut['type'] = $aut_array[$i]['type_auteur']; $aut['date'] = clean_string($aut_array[$i]['date']); $aut['subdivision'] = clean_string($aut_array[$i]['subdivision']); $aut['numero'] = clean_string($aut_array[$i]['numero']); $aut['lieu'] = clean_string($aut_array[$i]['lieu']); $aut['ville'] = clean_string($aut_array[$i]['ville']); $aut['pays'] = clean_string($aut_array[$i]['pays']); $aut['web'] = clean_string($aut_array[$i]['web']); $aut['author_comment'] = clean_string($aut_array[$i]['author_comment']); $aut['authority_number'] = clean_string($aut_array[$i]['authority_number']); //si on à demander la prise en compte des numéro d'autorités if ($authorities_notices && $aut['authority_number'] != "") { $aut_array[$i]["id"] = keep_authority_infos($aut['authority_number'], "author", $origin_authority, $notice_id, $aut); } if (!$aut_array[$i]["id"]) { $aut_array[$i]["id"] = auteur::import($aut); } $aut_array[$i]['fonction'] = trim($aut_array[$i]['fonction']); if ($aut_array[$i]["id"]) { if ($values != "") { $values .= ","; } $values .= " ('" . $aut_array[$i]["id"] . "','" . $notice_id . "','" . addslashes($aut_array[$i]['fonction']) . "','" . $aut_array[$i]['responsabilite'] . "','" . $aut_array[$i]['ordre'] . "') "; // $rqt = $rqt_ins . " ('".$aut_array[$i]["id"]."','".$notice_id."','".addslashes($aut_array[$i]['fonction'])."','".$aut_array[$i]['responsabilite']."','".$aut_array[$i]['ordre']."') " ; // @mysql_query($rqt, $dbh); } } @mysql_query($rqt_ins . $values); } // Titres uniformes global $pmb_use_uniform_title; if ($pmb_use_uniform_title) { $nb_tu = sizeof($tu_500); for ($i = 0; $i < $nb_tu; $i++) { $value_tu[$i]['name'] = $tu_500[$i]['a']; $value_tu[$i]['tonalite'] = $tu_500[$i]['u']; $value_tu[$i]['comment'] = $tu_500[$i]['n']; $value_tu[$i]['authority_number'] = $tu_500[$i]['3']; for ($j = 0; $j < count($tu_500_r[$i]); $j++) { $value_tu[$i]['distrib'][$j] = $tu_500_r[$i][$j]; } for ($j = 0; $j < count($tu_500_s[$i]); $j++) { $value_tu[$i]['ref'][$j] = $tu_500_s[$i][$j]; } for ($j = 0; $j < count($tu_500_j[$i]); $j++) { $value_tu[$i]['subdiv'][$j] = $tu_500_j[$i][$j]; } if ($authorities_notices && $aut['authority_number'] != "") { $tu_id = keep_authority_infos($value_tu[$i]['authority_number'], "uniform_title", $origin_authority, $notice_id, $value_tu[$i]); } else { $tu_id = titre_uniforme::import($value_tu[$i]); } if ($tu_id) { $requete = "INSERT INTO notices_titres_uniformes SET \n\t\t\t\t\tntu_num_notice='{$notice_id}', \n\t\t\t\t\tntu_num_tu='{$tu_id}', \n\t\t\t\t\tntu_titre='" . addslashes($tu_500[$i]['i']) . "', \n\t\t\t\t\tntu_date='" . addslashes($tu_500[$i]['k']) . "', \n\t\t\t\t\tntu_sous_vedette='" . addslashes($tu_500[$i]['l']) . "', \n\t\t\t\t\tntu_langue='" . addslashes($tu_500[$i]['m']) . "', \n\t\t\t\t\tntu_version='" . addslashes($tu_500[$i]['q']) . "', \n\t\t\t\t\tntu_mention='" . addslashes($tu_500[$i]['w']) . "',\n\t\t\t\t\tntu_ordre={$i} \t\t\t\t\n\t\t\t\t\t"; mysql_query($requete, $dbh); } } } global $lang_code; global $org_lang_code; $rqt_ins = "insert into notices_langues (num_notice, type_langue, code_langue, ordre_langue) VALUES "; $values = ""; for ($i = 0; $i < count($lang_code); $i++) { $lang_code[$i] = trim($lang_code[$i]); if ($values != "") { $values .= ","; } $values .= "('{$notice_id}',0, '" . addslashes($lang_code[$i]) . "','{$i}') "; //$rqt_ins = "insert into notices_langues (num_notice, type_langue, code_langue) VALUES ('$notice_id',0, '".addslashes($lang_code[$i])."') " ; //@mysql_query($rqt_ins, $dbh); } for ($i = 0; $i < count($org_lang_code); $i++) { $org_lang_code[$i] = trim($org_lang_code[$i]); if ($values != "") { $values .= ","; } $values .= "('{$notice_id}',1, '" . addslashes($org_lang_code[$i]) . "','" . $i . "') "; //$rqt_ins = "insert into notices_langues (num_notice, type_langue, code_langue) VALUES ('$notice_id',1, '".addslashes($org_lang_code[$i])."') " ; // @mysql_query($rqt_ins, $dbh); } @mysql_query($rqt_ins . $values, $dbh); //Import des catégories category_auto::save_info_categ(); //Calcule de la signature $sign = new notice_doublon(); $val = $sign->gen_signature($notice_id); mysql_query("update notices set signature='{$val}' where notice_id=" . $notice_id, $dbh); //Si on a un id de notice et qu'il n'est pas dans le tableau des notices créées, on l'ajoute if ($link_generate && trim($id_unimarc) !== "" && !$notices_crees[$id_unimarc]) { $notices_crees[$id_unimarc] = $notice_id; } elseif ($link_generate && trim($id_unimarc) !== "" && $notices_crees[$id_unimarc]) { //Si la notice a déjà été créé (Export des liens dans les notices liées) on remplace celle précédemment par celle en cour de traitement $niveau_biblio = $bibliographic_level . $hierarchic_level; switch ($niveau_biblio) { case 'm0': //On a une notice de monographie $notice_a_supp = $notices_crees[$id_unimarc]; //On garde les liens $requete = "UPDATE notices_relations SET num_notice='" . $notice_id . "' WHERE num_notice='" . $notice_a_supp . "' "; @mysql_query($requete, $dbh); $requete = "UPDATE notices_relations SET linked_notice='" . $notice_id . "' WHERE linked_notice='" . $notice_a_supp . "' "; @mysql_query($requete, $dbh); $ma_notice = new notice($notice_a_supp); $ma_notice->replace($notice_id); break; case 's1': //On a une notice de periodique $notice_a_supp = $notices_crees[$id_unimarc]; $ma_notice = new serial($notice_a_supp); $ma_notice->replace($notice_id); break; case 'b2': //On a une notice de bulletin $notice_a_supp = $notices_crees[$id_unimarc]; //Dans les bulletins $requete = "update bulletins set num_notice='" . $notice_id . "' where num_notice='" . $notice_a_supp . "' "; mysql_query($requete, $dbh); //Dans les relations entre notice $requete = "update notices_relations set num_notice='" . $notice_id . "' where num_notice='" . $notice_a_supp . "'"; mysql_query($requete, $dbh); $requete = "update notices_relations set linked_notice='" . $notice_id . "' where linked_notice='" . $notice_a_supp . "'"; mysql_query($requete, $dbh); notice::del_notice($notice_a_supp); break; case 'a2': //On a une notice d'article $notice_a_supp = $notices_crees[$id_unimarc]; //Dans les bulletins $requete = "update analysis set analysis_notice='" . $notice_id . "' where analysis_notice='" . $notice_a_supp . "' "; mysql_query($requete, $dbh); //Dans les relations entre notice $requete = "update notices_relations set num_notice='" . $notice_id . "' where num_notice='" . $notice_a_supp . "'"; mysql_query($requete, $dbh); $requete = "update notices_relations set linked_notice='" . $notice_id . "' where linked_notice='" . $notice_a_supp . "'"; mysql_query($requete, $dbh); notice::del_notice($notice_a_supp); break; } $notices_crees[$id_unimarc] = $notice_id; } }
} } if ($bt_ajouter == "no") { $bouton_ajouter = ""; } else { $bouton_ajouter = "<input type='button' class='bouton_small' onclick=\"document.location='{$base_url}&action=add&deb_rech='+this.form.f_user_input.value+'&no_display={$no_display}'\" value='{$msg['339']}' />"; } switch ($action) { case 'add': $serie_form = str_replace("!!deb_saisie!!", htmlentities(stripslashes($f_user_input), ENT_QUOTES, $charset), $serie_form); print $serie_form; break; case 'update': $value = $serie_nom; require_once "{$class_path}/serie.class.php"; $serie = new serie(0); $serie->update($value); $sel_search_form = str_replace("!!bouton_ajouter!!", $bouton_ajouter, $sel_search_form); $sel_search_form = str_replace("!!deb_rech!!", htmlentities(stripslashes($f_user_input), ENT_QUOTES, $charset), $sel_search_form); print $sel_search_form; print $jscript; show_results($dbh, $serie_nom, 0, 0, $serie->id); break; default: $sel_search_form = str_replace("!!bouton_ajouter!!", $bouton_ajouter, $sel_search_form); $sel_search_form = str_replace("!!deb_rech!!", htmlentities(stripslashes($f_user_input), ENT_QUOTES, $charset), $sel_search_form); print $sel_search_form; print $jscript; show_results($dbh, $user_input, $nbr_lignes, $page); break; }
public function huecos() { $error = TRUE; $huecolist = $this->cache->get_array2('factura_cliente_huecos', $error, TRUE); if ($error) { $ejercicio = new ejercicio(); $serie = new serie(); foreach ($ejercicio->all_abiertos() as $eje) { $codserie = ''; $num = 1; $data = $this->db->select("SELECT codserie," . $this->db->sql_to_int('numero') . " as numero,fecha,hora\n FROM " . $this->table_name . " WHERE codejercicio = " . $this->var2str($eje->codejercicio) . " ORDER BY codserie ASC, numero ASC;"); if ($data) { foreach ($data as $d) { if ($d['codserie'] != $codserie) { $codserie = $d['codserie']; $num = 1; if (defined('FS_NFACTURA_CLI')) { /// mantenemos compatibilidad con versiones anteriores $num = intval(FS_NFACTURA_CLI); } $se = $serie->get($codserie); if ($se) { /// ¿Se ha definido un nº inicial de factura para esta serie y ejercicio? if ($eje->codejercicio == $se->codejercicio) { $num = $se->numfactura; } } } if (intval($d['numero']) < $num) { /** * El número de la factura es menor que el inicial. * El usuario ha cambiado el número inicial después de hacer * facturas. */ } else { if (intval($d['numero']) == $num) { /// el número es correcto, avanzamos $num++; } else { /// Hemos encontrado un hueco y debemos usar el número y la fecha. while ($num < intval($d['numero'])) { $huecolist[] = array('codigo' => $eje->codejercicio . sprintf('%02s', $codserie) . sprintf('%06s', $num), 'fecha' => Date('d-m-Y', strtotime($d['fecha'])), 'hora' => $d['hora']); $num++; } /// avanzamos uno más $num++; } } } } } $this->cache->set('factura_cliente_huecos', $huecolist, 3600, TRUE); } return $huecolist; }
/** * Devuelve un array con los huecos en la numeración. * @return type */ public function huecos() { $error = TRUE; $huecolist = $this->cache->get_array2('factura_cliente_huecos', $error); if ($error) { $ejercicio = new ejercicio(); $serie = new serie(); foreach ($ejercicio->all_abiertos() as $eje) { $codserie = ''; $num = 1; $data = $this->db->select("SELECT codserie," . $this->db->sql_to_int('numero') . " as numero,fecha,hora\n FROM " . $this->table_name . " WHERE codejercicio = " . $this->var2str($eje->codejercicio) . " ORDER BY codserie ASC, numero ASC;"); if ($data) { foreach ($data as $d) { if ($d['codserie'] != $codserie) { $codserie = $d['codserie']; $num = 1; $se = $serie->get($codserie); if ($se) { /// ¿Se ha definido un nº inicial de factura para esta serie y ejercicio? if ($eje->codejercicio == $se->codejercicio) { $num = $se->numfactura; } } } if (intval($d['numero']) < $num) { /** * El número de la factura es menor que el inicial. * El usuario ha cambiado el número inicial después de hacer * facturas. */ } else { if (intval($d['numero']) == $num) { /// el número es correcto, avanzamos $num++; } else { /** * Hemos encontrado un hueco y debemos usar el número y la fecha. * La variable pasos permite dejar de añadir huecos al llegar a 100, * así evitamos agotar la memoria en caso de error grave. */ $pasos = 0; while ($num < intval($d['numero']) and $pasos < 100) { $huecolist[] = array('codigo' => $eje->codejercicio . sprintf('%02s', $codserie) . sprintf('%06s', $num), 'fecha' => Date('d-m-Y', strtotime($d['fecha'])), 'hora' => $d['hora']); $num++; $pasos++; } /// avanzamos uno más $num++; } } } } } $this->cache->set('factura_cliente_huecos', $huecolist, 3600); } return $huecolist; }
private function sync() { $continuar = TRUE; $art0 = new articulo(); $ej0 = new ejercicio(); $serie0 = new serie(); $div0 = new divisa(); foreach (array_reverse($this->pedidos) as $ped) { $data = $this->db->select("SELECT * FROM albaranescli WHERE numero2 = " . $art0->var2str($this->order_numero2($ped->order_number)) . ";"); if (!$data and $continuar and $ped->status == 'completed') { $albaran = new albaran_cliente(); $albaran->numero2 = $this->order_numero2($ped->order_number); $albaran->fecha = Date('d-m-Y', strtotime($ped->created_at)); $albaran->hora = Date('H:i:s', strtotime($ped->created_at)); $albaran->observaciones = 'Este pedido ha sido importado con la demo de woocommerce, por eso no se ha asignado el cliente.'; $albaran->cifnif = ''; $albaran->direccion = ''; $ejercicio = $ej0->get_by_fecha($albaran->fecha); if ($ejercicio) { $albaran->codejercicio = $ejercicio->codejercicio; $serie = $serie0->get($this->setup['wooc_serie']); if ($serie) { $albaran->codserie = $serie->codserie; $albaran->irpf = $serie->irpf; $albaran->codalmacen = $this->setup['wooc_alm']; $divisa = $div0->get($this->empresa->coddivisa); if ($divisa) { $albaran->coddivisa = $divisa->coddivisa; $albaran->tasaconv = $divisa->tasaconv; } $albaran->codpago = $this->empresa->codpago; if ($albaran->save()) { foreach ($ped->line_items as $l) { $linea = new linea_albaran_cliente(); $linea->idalbaran = $albaran->idalbaran; $linea->referencia = $l->sku; $linea->descripcion = $l->name; $linea->cantidad = $l->quantity; $linea->irpf = $albaran->irpf; $articulo = $art0->get($l->sku); if ($articulo and !$serie->siniva and $cliente->regimeniva != 'Exento') { $linea->codimpuesto = $articulo->codimpuesto; $linea->iva = $articulo->get_iva(); } $linea->pvpunitario = 100 * $l->total / $l->quantity / (100 + $linea->iva); $linea->pvptotal = $linea->pvpsindto = $linea->pvpunitario * $linea->cantidad; if ($linea->save()) { /// descontamos del stock if ($articulo) { $articulo->sum_stock($albaran->codalmacen, 0 - $linea->cantidad); } $albaran->neto += $linea->pvptotal; $albaran->totaliva += $linea->pvptotal * $linea->iva / 100; $albaran->totalirpf += $linea->pvptotal * $linea->irpf / 100; $albaran->totalrecargo += $linea->pvptotal * $linea->recargo / 100; } else { $this->new_error_msg("¡Imposible guardar la linea con referencia: " . $linea->referencia); $continuar = FALSE; } } /// cupones foreach ($ped->coupon_lines as $l) { $linea = new linea_albaran_cliente(); $linea->idalbaran = $albaran->idalbaran; $linea->descripcion = 'Cupón: ' . $l->code; $linea->cantidad = -1; $linea->irpf = $albaran->irpf; if (!$serie->siniva and $cliente->regimeniva != 'Exento') { $impuesto = $this->impuesto->get($this->setup['wooc_imp']); if ($impuesto) { $linea->codimpuesto = $impuesto->codimpuesto; $linea->iva = $impuesto->iva; } } $linea->pvpunitario = 100 * floatval($l->amount) / (100 + $linea->iva); $linea->pvptotal = $linea->pvpsindto = $linea->pvpunitario * $linea->cantidad; if ($linea->save()) { $albaran->neto += $linea->pvptotal; $albaran->totaliva += $linea->pvptotal * $linea->iva / 100; $albaran->totalirpf += $linea->pvptotal * $linea->irpf / 100; $albaran->totalrecargo += $linea->pvptotal * $linea->recargo / 100; } else { $this->new_error_msg("¡Imposible guardar la linea del cupón: " . $l->code); $continuar = FALSE; } } if ($continuar) { /// redondeamos $albaran->neto = round($albaran->neto, FS_NF0); $albaran->totaliva = round($albaran->totaliva, FS_NF0); $albaran->totalirpf = round($albaran->totalirpf, FS_NF0); $albaran->totalrecargo = round($albaran->totalrecargo, FS_NF0); $albaran->total = $albaran->neto + $albaran->totaliva - $albaran->totalirpf + $albaran->totalrecargo; if ($albaran->save()) { $this->new_message("<a href='" . $albaran->url() . "'>" . ucfirst(FS_ALBARAN) . "</a> guardado correctamente."); $this->new_change(ucfirst(FS_ALBARAN) . ' Cliente ' . $albaran->codigo, $albaran->url(), TRUE); } else { $this->new_error_msg("¡Imposible actualizar el <a href='" . $albaran->url() . "'>" . FS_ALBARAN . "</a>!"); $continuar = FALSE; } } else { if ($albaran->delete()) { $this->new_message(ucfirst(FS_ALBARAN) . " eliminado correctamente."); } else { $this->new_error_msg("¡Imposible eliminar el <a href='" . $albaran->url() . "'>" . FS_ALBARAN . "</a>!"); $continuar = FALSE; } } } else { $this->new_error_msg('Error al guardar los datos del ' . FS_ALBARAN . ' ' . $ped->order_number); $continuar = FALSE; } } else { $this->new_error_msg('Imposible encontrar una serie para el ' . FS_ALBARAN . ' ' . $ped->order_number); $continuar = FALSE; } } else { $this->new_error_msg('Imposible encontrar un ejercicio para el ' . FS_ALBARAN . ' ' . $ped->order_number); $continuar = FALSE; } break; } } $this->new_advice('Esto es una demo. La versión completa importa todos los pedidos completados, incluyendo clientes y artículos. ' . '<a href="https://www.facturascripts.com/store/producto/plugin-woocommerce/" target="_blank">' . '<span class="glyphicon glyphicon-shopping-cart"></span> comprar la versión completa</a>'); }
public function stats_series($tabla = 'facturasprov') { $stats = array(); $serie0 = new serie(); $sql = "select codserie,sum(totaleuros) as total from " . $tabla . " group by codserie order by total desc;"; $data = $this->db->select($sql); if ($data) { foreach ($data as $d) { $serie = $serie0->get($d['codserie']); if ($serie) { $stats[] = array('txt' => $serie->descripcion, 'total' => round(abs($this->euro_convert(floatval($d['total']))), FS_NF0)); } else { $stats[] = array('txt' => $d['codserie'], 'total' => round(abs($this->euro_convert(floatval($d['total']))), FS_NF0)); } } } return $stats; }
$acces_j = $dom_2->getJoin($_SESSION['id_empr_session'], 4, 'notice_id'); } if ($acces_j) { $statut_j = ''; $statut_r = ''; } else { $statut_j = ',notice_statut'; $statut_r = "and statut=id_notice_statut and ((notice_visible_opac=1 and notice_visible_opac_abon=0)" . ($_SESSION["user_code"] ? " or (notice_visible_opac_abon=1 and notice_visible_opac=1)" : "") . ")"; } print "<div id='aut_details'>\n\n\t\t<h3><span>" . $msg["serie_see_title"] . "</span></h3>\n"; print "<div id='aut_details_container'>\n"; if ($id) { $id += 0; // affichage des informations sur l'éditeur print "<div id='aut_see'>\n"; $ourSerie = new serie($id); print pmb_bidi($ourSerie->print_resume()); $aut_link = new aut_link(AUT_TABLE_SERIES, $id); print pmb_bidi($aut_link->get_display()); print "</div><!-- fermeture #aut_see -->\n"; // affichage des notices associées print "\t<div id='aut_details_liste'>\n\n\t\t\t<h3>{$msg['doc_serie_title']}</h3>\n"; // comptage des notices associées if (!$nbr_lignes) { //$requete = "SELECT COUNT(notice_id) FROM notices, notice_statut "; //$requete .= " where tparent_id='$id' and (statut=id_notice_statut and ((notice_visible_opac=1 and notice_visible_opac_abon=0)".($_SESSION["user_code"]?" or (notice_visible_opac_abon=1 and notice_visible_opac=1)":"")."))"; $requete = "SELECT COUNT(*) FROM notices {$acces_j} {$statut_j} where tparent_id={$id} {$statut_r} "; $res = mysql_query($requete, $dbh); $nbr_lignes = @mysql_result($res, 0, 0); //Recherche des types doc //$requete="select distinct notices.typdoc FROM notices, notice_statut ";