/** * Load an object from its id and create a new one in database * * @param int $fromid Id of object to clone * @return int New id of clone */ function createFromClone($fromid) { global $user, $langs; $error = 0; $object = new Immocompteurlocal($this->db); $this->db->begin(); // Load source object $object->fetch($fromid); $object->id = 0; $object->statut = 0; // Clear fields // ... // Create clone $result = $object->create($user); // Other options if ($result < 0) { $this->error = $object->error; $error++; } if (!$error) { } // End if (!$error) { $this->db->commit(); return $object->id; } else { $this->db->rollback(); return -1; } }
function select_compteur_by_local($selectid, $local_id, $htmlname = 'compteur', $showempty = 0, $event = array()) { global $conf, $user, $langs; require_once 'compteur_local.class.php'; $compteur_local = new Immocompteurlocal($this->db); $result = $compteur_local->fetch_all_by_local($local_id); if ($result < 0) { setEventMessage($compteur_local->error, 'errors'); } $out = ''; $out .= ajax_combobox($htmlname, $event); $out .= '<select id="' . $htmlname . '" class="flat" name="' . $htmlname . '">'; if (is_array($compteur_local->lines) && count($compteur_local->lines) > 0) { if ($showempty) { $out .= '<option value=""></option>'; } foreach ($compteur_local->lines as $line) { $label = $line->type . '-' . $line->label; if ($selectid != '' && $selectid == $obj->fournisseur) { $out .= '<option value="' . $line->id . '" selected="selected">' . $label . '</option>'; } else { $out .= '<option value="' . $line->id . '">' . $label . '</option>'; } } } $out .= '</select>'; return $out; }
print '<tr><td>'; print $langs->trans('CreateCompteurForThisLocal'); print '</td></tr>'; print '<tr><td>'; print $htmlimmo->select_type_compteur(''); print '<input type="text" size="5" name="nom_compteur"/>'; print '<input type="submit" value="' . $langs->trans('Add') . '"/>'; print '</td></tr>'; print '</table>'; print '</form>'; //Liste des compteurs print '<table>'; print '<tr><td>'; print $langs->trans('ListCompteurForThisBulding'); print '</td></tr>'; $compteur_local = new Immocompteurlocal($db); $result = $compteur_local->fetch_all_by_local($id); if ($result < 0) { setEventMessage($compteur_local->error, 'errors'); } foreach ($compteur_local->lines as $line) { print '<tr><td>'; print $line->type . '-' . $line->label; print '</td></tr>'; } print '</table>'; print '</td>'; //Ajouter un relevé print '<td>'; print $langs->trans('AddRelever'); print '<form action="' . $_SERVER['SELF'] . '" method="post" name="addrelever">';