function camila_db_onupdate_message(&$lform) { global $_CAMILA; $_CAMILA['update_result_desc'] = camila_get_translation('camila.form.data.updated'); camila_information_text($_CAMILA['update_result_desc']); return true; }
function operation($id, $operation, $returl) { global $_CAMILA; if ($operation == 'delete') { require_once CAMILA_DIR . 'datagrid/form.class.php'; require_once CAMILA_DIR . 'datagrid/elements/form/hidden.php'; $form3 = new phpform('camila', 'cf_worktable_admin.php'); $form3->submitbutton = camila_get_translation('camila.worktable.delete'); $form3->drawrules = false; new form_hidden($form3, 'custom', $id); new form_hidden($form3, 'worktable_op', $operation); if ($returl != '') { new form_hidden($form3, 'returl', $returl); } if ($form3->process()) { $result = $_CAMILA['db']->Execute('select tablename,scriptname from ' . CAMILA_TABLE_WORKT . ' where id=' . $_CAMILA['db']->qstr($id)); if ($result === false) { camila_error_page(camila_get_translation('camila.sqlerror') . ' ' . $_CAMILA['db']->ErrorMsg()); } $table = $result->fields['tablename']; $script = $result->fields['scriptname']; $result = $_CAMILA['db']->Execute('delete from ' . CAMILA_TABLE_WORKT . ' where id=' . $_CAMILA['db']->qstr($id)); if ($result === false) { camila_error_page(camila_get_translation('camila.sqlerror') . ' ' . $_CAMILA['db']->ErrorMsg()); } $result = $_CAMILA['db']->Execute('delete from ' . CAMILA_TABLE_WORKC . ' where (wt_id=' . $_CAMILA['db']->qstr($id) . ' and is_deleted<>' . $_CAMILA['db']->qstr('y') . ')'); if ($result === false) { camila_error_page(camila_get_translation('camila.sqlerror') . ' ' . $_CAMILA['db']->ErrorMsg()); } $stmt = sprintf($_CAMILA['db']->_dropSeqSQL, $table); $result = $_CAMILA['db']->Execute($stmt); //if ($result === false) // camila_error_page(camila_get_translation('camila.sqlerror') . ' ' . $_CAMILA['db']->ErrorMsg()); $record = array(); $record['visible'] = 'no'; $record['active'] = 'no'; $updateSQL = $_CAMILA['db']->AutoExecute(CAMILA_TABLE_PAGES, $record, 'UPDATE', 'url=' . $_CAMILA['db']->qstr($script)); //if (!$updateSQL) { // camila_information_text(camila_get_translation('camila.worktable.db.error')); // $success3 = false; //} } else { camila_information_text(camila_get_translation('camila.worktable.delete.areyousure')); $result = $_CAMILA['db']->Execute('select short_title from ' . CAMILA_TABLE_WORKT . ' where id=' . $_CAMILA['db']->qstr($id)); if ($result === false) { camila_error_page(camila_get_translation('camila.sqlerror') . ' ' . $_CAMILA['db']->ErrorMsg()); } $name = $result->fields['short_title']; $myText = new CHAW_text($name, HAW_TEXTFORMAT_BOLD); $myText->set_br(2); $_CAMILA['page']->add_text($myText); $form3->draw(); $success = false; } } elseif ($operation == 'rebuild') { require_once CAMILA_DIR . 'datagrid/form.class.php'; require_once CAMILA_DIR . 'datagrid/elements/form/hidden.php'; $form3 = new phpform('camila', 'cf_worktable_admin.php'); $form3->submitbutton = camila_get_translation('camila.worktable.delete'); $form3->drawrules = false; new form_hidden($form3, 'custom', $id); new form_hidden($form3, 'worktable_op', $operation); if ($returl != '') { new form_hidden($form3, 'returl', $returl); } if ($form3->process()) { $this->configure_table($id, true, $returl); } else { camila_information_text(camila_get_translation('camila.worktable.rebuild.areyousure')); $result = $_CAMILA['db']->Execute('select short_title from ' . CAMILA_TABLE_WORKT . ' where id=' . $_CAMILA['db']->qstr($id)); if ($result === false) { camila_error_page(camila_get_translation('camila.sqlerror') . ' ' . $_CAMILA['db']->ErrorMsg()); } $name = $result->fields['short_title']; $myText = new CHAW_text($name, HAW_TEXTFORMAT_BOLD); $myText->set_br(2); $_CAMILA['page']->add_text($myText); $form3->draw(); $success = false; } } elseif ($operation == 'showtemplatefields') { $stmt = "select wt_id,name,name_abbrev,col_name as colname_form, col_name as colname_table from " . CAMILA_TABLE_WORKC . ' where (wt_id=' . $_CAMILA['db']->qstr($id) . ' and is_deleted<>' . $_CAMILA['db']->qstr('y') . ') order by name'; require_once CAMILA_DIR . 'datagrid/report.class.php'; $report = new report($stmt); $report->mapping = camila_get_translation('camila.worktable.mapping.worktable'); $report->process(); $report->fields['colname_form']->onprint = camila_configurator_template_fieldname_form; $report->fields['colname_form']->dummy = true; $report->fields['colname_form']->orderable = false; $report->fields['colname_table']->onprint = camila_configurator_template_fieldname_table; $report->fields['colname_table']->dummy = true; $report->fields['colname_table']->orderable = false; $report->fields['wt_id']->print = false; $report->fields['name']->orderable = false; $report->fields['name_abbrev']->orderable = false; $report->drawfilterbox = false; $report->drawnavigationbox = false; $report->draw(); } if ($success) { $myText = new CHAW_text(camila_get_translation('camila.worktable.db.importok')); $_CAMILA['page']->add_text($myText); } }
function XLS_import2($file, $table, $db) { $filename = basename($file); $sequence = intval(substr($filename, 0, strpos($filename, '_'))); $res = $db->Execute('select id from ' . CAMILA_TABLE_WORKT . ' where filename=' . $db->qstr($filename)); if ($res === false) { camila_error_page(camila_get_translation('camila.sqlerror') . ' ' . $db->ErrorMsg()); } $id = $res->fields['id']; $result = array(); $configurator = new configurator(); $configurator->filename = $file; $configurator->sheetnum = 0; $configurator->interactive = false; $db->SetFetchMode(ADODB_FETCH_ASSOC); $configurator->db = $db; $configurator->configure_table($id, false); $record = array(); $res = $db->Execute('select * from ' . CAMILA_TABLE_WORKT . ' where id=' . $db->qstr($id)); if ($res === false) { camila_error_page(camila_get_translation('camila.sqlerror') . ' ' . $db->ErrorMsg()); } $record['short_title'] = $res->fields['short_title']; $record['full_title'] = $res->fields['full_title']; $record['label_order'] = $sequence; $scriptname = $res->fields['scriptname']; $category = $res->fields['category']; $updateSQL = $db->AutoExecute(CAMILA_TABLE_PLANG, $record, 'UPDATE', 'page_url=' . $db->qstr($scriptname) . ' and lang=' . $db->qstr($_REQUEST['lang'])); if (!$updateSQL) { camila_information_text(camila_get_translation('camila.worktable.db.error')); } if (trim($category) != '') { $res = $db->Execute('select page_url from ' . CAMILA_TABLE_PLANG . ' where short_title=' . $db->qstr($category) . ' AND page_url LIKE ' . $db->qstr('cf_app.php?cat%') . ' and lang=' . $db->qstr($_REQUEST['lang'])); if ($res === false) { camila_error_page(camila_get_translation('camila.sqlerror') . ' ' . $db->ErrorMsg()); } $cat_url = '-'; if ($res->RecordCount() == 0) { $res = $db->Execute('select page_url from ' . CAMILA_TABLE_PLANG . ' where full_title<>' . $db->qstr('-') . ' AND page_url LIKE ' . $db->qstr('cf_app.php?cat%') . ' and lang=' . $db->qstr($_REQUEST['lang'])); if ($res === false) { camila_error_page(camila_get_translation('camila.sqlerror') . ' ' . $db->ErrorMsg()); } $cat_url = $res->fields['page_url']; $record = array(); $record['label_order'] = $sequence; $record['short_title'] = $category; $record['full_title'] = '-'; $updateSQL = $db->AutoExecute(CAMILA_TABLE_PLANG, $record, 'UPDATE', 'page_url=' . $db->qstr($cat_url) . ' and lang=' . $db->qstr($_REQUEST['lang'])); if (!$updateSQL) { camila_information_text(camila_get_translation('camila.worktable.db.error')); } } else { $cat_url = $res->fields['page_url']; } $record = array(); $record['parent'] = $cat_url; $updateSQL = $db->AutoExecute(CAMILA_TABLE_PAGES, $record, 'UPDATE', 'url=' . $db->qstr($scriptname)); if (!$updateSQL) { camila_information_text(camila_get_translation('camila.worktable.db.error')); } $record = array(); $record['visible'] = 'yes'; $updateSQL = $db->AutoExecute(CAMILA_TABLE_PAGES, $record, 'UPDATE', 'url=' . $db->qstr($cat_url)); if (!$updateSQL) { camila_information_text(camila_get_translation('camila.worktable.db.error')); } } $result['result'] = 2; //success $result['processed'] = 1; $result['failed'] = 0; return $result; }
function draw() { if (isset($_REQUEST['camila_editcols']) && ($_REQUEST['camila_editcols'] = 'y')) { $this->_editcolumns(); return; } $this->draw_filter(); if ($this->totalrows > 0) { $i = 0; $arr = array(); reset($this->keys); foreach ($this->keys as $afield) { if (strpos($afield, '.') !== false) { $field = substr($afield, 0, strpos($afield, '.')) . '__' . substr($afield, strpos($afield, '.') + 1); } else { $field = $afield; } if ($i < count($this->keys) - 1) { $this->fields['camilakey_' . $field]->print = false; } else { // if ($this->canupdate) $this->fields['camilakey_' . $field]->onprint = $this->formupdatefunction; if ($this->candelete) { $this->fields['camilakey_del_' . $field]->onprint = "camila_formdeletelink"; } } $i++; } $i = 0; $row = array(); $this->draw_header(); while ($this->load_row($row, $i++)) { if (isset($this->onloadrow)) { $func = $this->onloadrow; $ok = $func($this); } else { $ok = true; } if ($ok) { // check if group changed if (isset($this->group_field)) { if ($this->group_value != $this->fields[$this->group_field]->value) { $this->group_value = $this->fields[$this->group_field]->value; $this->draw_group(); } } $this->draw_row(); } } if (isset($_REQUEST['camila_countorderby']) && $this->rowcount > 0) { global $_CAMILA; $myRow2 = new CHAW_row(); $text = camila_get_translation('camila.report.countorderby.total') . " '" . $this->lastorderbyvalue . "': " . $this->currvalcount; $text1 = new CHAW_text($text); $myRow2->add_column($text1); $text2 = new CHAW_text(""); for ($i = 0; $i < $_CAMILA['page']->header_cols_count - 1; $i++) { $myRow2->add_column($text2); } $this->table->add_row($myRow2); $this->currvalcount = 0; } $this->draw_footer(); $text = new CHAW_text(''); global $_CAMILA; $_CAMILA['page']->add_text($text); // $code = "<div id='camilatablemenu' class='camilaWorkTableRSMenu'><p><b>Menu 1</b></p><p><a href=''>item 1</a></p><p><a href=''>item 2</a></p><p><a href=''>item 3</a></p></div>"; // $js = new CHAW_js($code); // $_CAMILA['page']->add_userdefined($js); $_CAMILA['page']->add_table($this->table); $json = new Services_JSON(); $jarr2 = $json->encode($this->menuitems); $code = "<script>camila_addDOMLoadEvent ( function() {"; $code .= "var a = '" . str_replace(array("'", "\\u0000"), array("\\'", ""), $jarr2) . "'; camilatablemenu_init(a);} )</script>"; $_CAMILA['page']->camila_add_js($code); $text = new CHAW_text(''); $_CAMILA['page']->add_text($text); $this->draw_footer(); } else { global $_CAMILA; camila_information_text(camila_get_translation('camila.nodatafound')); $_CAMILA['datagrid_nodata'] = 1; if (isset($this->additional_links)) { foreach ($this->additional_links as $key => $value) { $text = new CHAW_text(' | '); $text->set_br(0); $_CAMILA['page']->add_text($text); $link = new CHAW_link($key, $value); if (is_object($this->additional_links_images[$key])) { $link->add_image($this->additional_links_images[$key]); } $link->set_br(0); $_CAMILA['page']->add_link($link); } } $text = new CHAW_text(''); $_CAMILA['page']->add_text($text); } }
function _newdir() { $this->_tree_checkup(); require_once CAMILA_DIR . 'datagrid/form.class.php'; require_once CAMILA_DIR . 'datagrid/elements/form/hidden.php'; require_once CAMILA_DIR . 'datagrid/elements/form/textbox.php'; require_once CAMILA_DIR . 'datagrid/elements/form/fm_dir_listbox.php'; $form = new phpform('camila'); $form->submitbutton = camila_get_translation('camila.create'); $form->drawrules = false; new form_hidden($form, 'update', 'newdir'); global $_CAMILA; $pos = strrpos($_CAMILA['page_url'], '?'); if ($pos !== false) { new form_hidden($form, substr($_CAMILA['page_url'], $pos + 1)); } new form_textbox($form, 'name', camila_get_translation('camila.fm.createdirwithname'), true, 30); new form_fm_dir_listbox($form, 'dir', camila_get_translation('camila.fm.intofolder'), $this->usergroup, true); $fp = $form->process(); if ($fp) { $this->_createdir($this->usergroup, $form->fields['dir']->value, $form->fields['name']->value); camila_information_text(camila_get_translation('camila.fm.dircreated')); } else { $form->draw(); } return $fp; }
new form_textbox($form, 'title', 'Titolo', true, 50, 50); $export_format = 'camila_bookmark'; //$url = $_SERVER['PHP_SELF'] . '?' . $_SERVER['QUERY_STRING']; //$url = ereg_replace("&" . $export_format, '', $url); //$url = ereg_replace("\?" . $export_format, '', $url); $url = $_SERVER['PHP_SELF'] . '?filter=' . $_REQUEST['camila_bookmark']; new form_hidden($form, 'url', $url); if ($form->process()) { $record = array(); $record['id'] = $_CAMILA['db']->GenID(CAMILA_APPLICATION_PREFIX . 'bookmarkseq', 10000) . camila_hash(10); $record['lang'] = $_CAMILA['lang']; $record['url'] = $form->fields['url']->value; $record['base_url'] = $form->fields['base_url']->value; $record['title'] = $form->fields['title']->value; $insertSQL = $_CAMILA['db']->AutoExecute(CAMILA_APPLICATION_PREFIX . 'camila_bookmarks', $record, 'INSERT'); if (!$insertSQL) { camila_information_text(camila_get_translation('camila.worktable.db.error')); $success = false; } $url = $form->fields['url']->value; } else { $form->draw(); } $myLink = new CHAW_link(camila_get_translation('camila.back.page'), $url); $myImage = new HAW_image(CAMILA_IMG_DIR . 'wbmp/resultset_previous.wbmp', CAMILA_IMG_DIR . 'png/resultset_previous.png', '-'); $myLink->add_image($myImage); $_CAMILA['page']->add_link($myLink); $_CAMILA['page']->use_simulator(CAMILA_CSS_DIR . 'skin0.css'); require CAMILA_DIR . 'deck_settings.php'; require CAMILA_DIR . 'footer.php'; exit;
Camila PHP Framework is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Camila PHP Framework; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ require CAMILA_LIB_DIR . '/adodb/toexport.inc.php'; require_once CAMILA_DIR . '/datagrid/form.class.php'; require_once CAMILA_DIR . '/datagrid/elements/form/static_listbox.php'; $options = ''; if (is_array($tables = $_CAMILA['db']->MetaTables('TABLES'))) { foreach ($tables as $table) { $options .= $table . ','; } } $form = new phpform('table', basename($_SERVER['PHP_SELF']) . '?dbexport'); new form_static_listbox($form, 'table', 'Table', $options, true); if ($form->process()) { $file = CAMILA_TABLES_DIR . '/' . $form->fields['table']->value . '.csv'; require_once CAMILA_DIR . 'db/export.inc.php'; $result = csv_export($form->fields['table']->value, $file, $_CAMILA['db']); ob_start(); print_r($result); $sql_r = ob_get_contents(); ob_end_clean(); camila_information_text('DATA EXPORT ' . $sql_r); } $form->draw();
along with Camila PHP Framework; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ require_once CAMILA_DIR . '/datagrid/form.class.php'; require_once CAMILA_DIR . '/datagrid/elements/form/static_listbox.php'; $options = ''; if (is_dir(CAMILA_TABLES_DIR)) { if ($dh = opendir(CAMILA_TABLES_DIR)) { while (($file = readdir($dh)) !== false) { if ($file != '.' && $file != '..' && substr($file, -3) == 'xml') { $options .= $file . ','; } } closedir($dh); } } $form = new phpform('schema', basename($_SERVER['PHP_SELF']) . '?dbschema'); //new form_static_listbox($form, 'prefix', 'Prefix', CAMILA_APP_DB_.','.CAMILA_DB_, true); new form_static_listbox($form, 'file', 'Schema', $options, true); new form_static_listbox($form, 'drop', 'Drop', 'N,Y', true); if ($form->process()) { require_once CAMILA_DIR . 'db/schema.inc.php'; $result = create_table(CAMILA_TABLES_DIR . '/' . $form->fields['file']->value, '', $_CAMILA['db'], $form->fields['drop']->value == 'Y' ? true : false); $results = array(0 => 'FAILURE', 1 => 'ERRORS', 2 => 'SUCCESSFUL'); ob_start(); print_r($results); print_r($result); $sql_r = ob_get_contents(); ob_end_clean(); camila_information_text('EXECUTE SCHEMA ' . $sql_r); } $form->draw();