// accessforbidden(); $entitytoicon = array('invoice' => 'bill', 'invoice_line' => 'bill', 'order' => 'order', 'order_line' => 'order', 'propal' => 'propal', 'propal_line' => 'propal', 'intervention' => 'intervention', 'inter_line' => 'intervention', 'member' => 'user', 'member_type' => 'group', 'subscription' => 'payment', 'payment' => 'payment', 'tax' => 'generic', 'tax_type' => 'generic', 'stock' => 'generic', 'other' => 'generic', 'account' => 'account', 'product' => 'product', 'warehouse' => 'stock', 'batch' => 'stock', 'category' => 'category', 'shipment' => 'sending', 'shipment_line' => 'sending', 'expensereport' => 'trip', 'expensereport_line' => 'trip', 'contract_line' => 'contract'); // Translation code $entitytolang = array('user' => 'User', 'company' => 'Company', 'contact' => 'Contact', 'invoice' => 'Bill', 'invoice_line' => 'InvoiceLine', 'order' => 'Order', 'order_line' => 'OrderLine', 'propal' => 'Proposal', 'propal_line' => 'ProposalLine', 'intervention' => 'Intervention', 'inter_line' => 'InterLine', 'member' => 'Member', 'member_type' => 'MemberType', 'subscription' => 'Subscription', 'tax' => 'SocialContribution', 'tax_type' => 'DictionarySocialContributions', 'account' => 'BankTransactions', 'payment' => 'Payment', 'product' => 'Product', 'service' => 'Service', 'stock' => 'Stock', 'batch' => 'Batch', 'warehouse' => 'Warehouse', 'category' => 'Category', 'other' => 'Other', 'trip' => 'TripsAndExpenses', 'shipment' => 'Shipments', 'shipment_line' => 'ShipmentLine', 'project' => 'Projects', 'projecttask' => 'Tasks', 'task_time' => 'TaskTimeSpent', 'action' => 'Event', 'expensereport' => 'ExpenseReport', 'expensereport_line' => 'ExpenseReportLine', 'contract' => 'Contract', 'contract_line' => 'ContractLine'); $array_selected = isset($_SESSION["export_selected_fields"]) ? $_SESSION["export_selected_fields"] : array(); $array_filtervalue = isset($_SESSION["export_filtered_fields"]) ? $_SESSION["export_filtered_fields"] : array(); $datatoexport = GETPOST("datatoexport"); $action = GETPOST('action', 'alpha'); $confirm = GETPOST('confirm', 'alpha'); $step = GETPOST("step") ? GETPOST("step") : 1; $export_name = GETPOST("export_name"); $hexa = GETPOST("hexa"); $exportmodelid = GETPOST("exportmodelid"); $field = GETPOST("field"); $objexport = new Export($db); $objexport->load_arrays($user, $datatoexport); $objmodelexport = new ModeleExports($db); $form = new Form($db); $htmlother = new FormOther($db); $formfile = new FormFile($db); $sqlusedforexport = ''; $upload_dir = $conf->export->dir_temp . '/' . $user->id; //$usefilters=($conf->global->MAIN_FEATURES_LEVEL > 1); $usefilters = 1; /* * Actions */ if ($action == 'selectfield') { $fieldsarray = $objexport->array_export_fields[0]; $fieldsentitiesarray = $objexport->array_export_entities[0]; $fieldsdependenciesarray = $objexport->array_export_dependencies[0];
/** * Test export function * * @return void */ public function testExportSociete() { global $conf,$user,$langs,$db; $sql = ""; $datatoexport='societe_1'; $array_selected = array("s.rowid"=>1, "s.nom"=>2); // Mut be fields found into declaration of dataset $model='csv'; $objexport=new Export($db); $result=$objexport->load_arrays($user,$datatoexport); // Build export file $result=$objexport->build_file($user, $model, $datatoexport, $array_selected, $sql); $expectedresult=1; $this->assertEquals($result,$expectedresult); return true; }
* You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ /** * \file htdocs/exports/index.php * \ingroup export * \brief Home page of export tools */ require_once "../main.inc.php"; require_once DOL_DOCUMENT_ROOT . "/exports/class/export.class.php"; $langs->load("exports"); if (!$user->rights->export->lire) { accessforbidden(); } $export = new Export($db); $export->load_arrays($user); /* * View */ $form = new Form($db); llxHeader('', $langs->trans("ExportsArea"), 'EN:Module_Exports_En|FR:Module_Exports|ES:Módulo_Exportaciones'); print_fiche_titre($langs->trans("ExportsArea")); print $langs->trans("FormatedExportDesc1") . '<br>'; print $langs->trans("FormatedExportDesc2") . ' '; print $langs->trans("FormatedExportDesc3") . '<br>'; print '<br>'; print '<table class="notopnoleftnoright" width="100%">'; print '<tr><td valign="top" width="40%" class="notopnoleft">'; // List of available export format $var = true; print '<table class="noborder" width="100%">';
/** * Test export function for all dataset predefined into modules * * @depends testExportPersonalizedWithFilter * @return void */ public function testExportModulesDatasets() { global $conf, $user, $langs, $db; $model = 'csv'; $filterdatatoexport = ''; //$filterdatatoexport=''; //$array_selected = array("s.rowid"=>1, "s.nom"=>2); // Mut be fields found into declaration of dataset // Load properties of arrays to make export $objexport = new Export($db); $result = $objexport->load_arrays($user, $filterdatatoexport); // This load ->array_export_xxx properties for datatoexport // Loop on each dataset foreach ($objexport->array_export_code as $key => $datatoexport) { $exportfile = $conf->export->dir_temp . '/' . $user->id . '/export_' . $datatoexport . '.csv'; print "Process export for dataset " . $datatoexport . " into " . $exportfile . "\n"; dol_delete_file($exportfile); // Generate $array_selected $i = 0; $array_selected = array(); foreach ($objexport->array_export_fields[$key] as $key => $val) { $array_selected[$key] = $i++; } //var_dump($array_selected); // Build export file $sql = ""; $result = $objexport->build_file($user, $model, $datatoexport, $array_selected, array(), $sql); $expectedresult = 1; $this->assertEquals($result, $expectedresult, 'Call build_file to export ' . $exportfile . ' failed'); $result = dol_is_file($exportfile); $this->assertTrue($result, $expectedresult, 'File ' . $exportfile . ' not found'); } return true; }