コード例 #1
0
ファイル: Misc.class.php プロジェクト: alachaum/timetrex
 static function Export2XML($factory_arr, $filter_data, $output_file)
 {
     global $global_class_map;
     $global_exclude_arr = array('Factory', 'FactoryListIterator', 'SystemSettingFactory', 'CronJobFactory', 'CompanyUserCountFactory', 'HelpFactory', 'HelpGroupControlFactory', 'HelpGroupFactory', 'HierarchyFactory', 'HierarchyShareFactory', 'JobUserAllowFactory', 'JobItemAllowFactory', 'PolicyGroupAccrualPolicyFactory', 'PolicyGroupOverTimePolicyFactory', 'PolicyGroupPremiumPolicyFactory', 'PolicyGroupRoundIntervalPolicyFactory', 'ProductTaxPolicyProductFactory');
     $dependency_tree = new DependencyTree();
     $i = 0;
     foreach ($global_class_map as $class => $file) {
         if (stripos($class, 'Factory') !== FALSE and stripos($class, 'API') === FALSE and stripos($class, 'ListFactory') === FALSE and stripos($class, 'Report') === FALSE and !in_array($class, $global_exclude_arr)) {
             if (isset($global_class_dependancy_map[$class])) {
                 $dependency_tree->addNode($class, $global_class_dependancy_map[$class], $class, $i);
             } else {
                 $dependency_tree->addNode($class, array(), $class, $i);
             }
         }
         $i++;
     }
     $ordered_factory_arr = $dependency_tree->getAllNodesInOrder();
     //Debug::Arr($ordered_factory_arr, 'Ordered Factory List: ', __FILE__, __LINE__, __METHOD__,10);
     if (is_array($factory_arr) and count($factory_arr) > 0) {
         Debug::Arr($factory_arr, 'Factory Filter: ', __FILE__, __LINE__, __METHOD__, 10);
         foreach ($ordered_factory_arr as $factory) {
             if (in_array($factory, $factory_arr)) {
                 $filtered_factory_arr[] = $factory;
             } else {
                 //Debug::Text('Removing factory: '. $factory .' due to filter...', __FILE__, __LINE__, __METHOD__,10);
             }
         }
     } else {
         Debug::Text('Not filtering factory...', __FILE__, __LINE__, __METHOD__, 10);
         $filtered_factory_arr = $ordered_factory_arr;
     }
     unset($ordered_factory_arr);
     if (isset($filtered_factory_arr) and count($filtered_factory_arr) > 0) {
         @unlink($output_file);
         $fp = bzopen($output_file, 'w');
         Debug::Arr($filtered_factory_arr, 'Filtered/Ordered Factory List: ', __FILE__, __LINE__, __METHOD__, 10);
         Debug::Text('Exporting data...', __FILE__, __LINE__, __METHOD__, 10);
         foreach ($filtered_factory_arr as $factory) {
             $class = str_replace('Factory', 'ListFactory', $factory);
             $lf = new $class();
             Debug::Text('Exporting ListFactory: ' . $factory . ' Memory Usage: ' . memory_get_usage() . ' Peak: ' . memory_get_peak_usage(TRUE), __FILE__, __LINE__, __METHOD__, 10);
             self::ExportListFactory2XML($lf, $filter_data, $fp);
             unset($lf);
         }
         bzclose($fp);
     } else {
         Debug::Text('No data to export...', __FILE__, __LINE__, __METHOD__, 10);
     }
 }
コード例 #2
0
 function getOrderedDeductionAndPSAmendment($udlf, $psalf, $uelf)
 {
     global $profiler;
     $dependency_tree = new DependencyTree();
     $deduction_order_arr = array();
     if (is_object($udlf)) {
         //Loop over all User Deductions getting Include/Exclude and PS accounts.
         if ($udlf->getRecordCount() > 0) {
             foreach ($udlf as $ud_obj) {
                 //Debug::text('User Deduction: ID: '. $ud_obj->getId(), __FILE__, __LINE__, __METHOD__,10);
                 if ($ud_obj->getCompanyDeductionObject()->getStatus() == 10) {
                     $global_id = substr(get_class($ud_obj), 0, 1) . $ud_obj->getId();
                     $deduction_order_arr[$global_id] = $this->getDeductionObjectArrayForSorting($ud_obj);
                     //Debug::Arr( array($deduction_order_arr[$global_id]['require_accounts'], $deduction_order_arr[$global_id]['affect_accounts']), 'Deduction Name: '. $deduction_order_arr[$global_id]['name'], __FILE__, __LINE__, __METHOD__,10);
                     $dependency_tree->addNode($global_id, $deduction_order_arr[$global_id]['require_accounts'], $deduction_order_arr[$global_id]['affect_accounts'], $deduction_order_arr[$global_id]['order']);
                 } else {
                     Debug::text('Company Deduction is DISABLED!', __FILE__, __LINE__, __METHOD__, 10);
                 }
             }
         }
     }
     unset($udlf, $ud_obj);
     if (is_object($psalf)) {
         if ($psalf->getRecordCount() > 0) {
             foreach ($psalf as $psa_obj) {
                 //Debug::text('PS Amendment ID: '. $psa_obj->getId(), __FILE__, __LINE__, __METHOD__,10);
                 $global_id = substr(get_class($psa_obj), 0, 1) . $psa_obj->getId();
                 $deduction_order_arr[$global_id] = $this->getDeductionObjectArrayForSorting($psa_obj);
                 $dependency_tree->addNode($global_id, $deduction_order_arr[$global_id]['require_accounts'], $deduction_order_arr[$global_id]['affect_accounts'], $deduction_order_arr[$global_id]['order']);
             }
         }
     }
     unset($psalf, $psa_obj);
     if (is_object($uelf)) {
         if ($uelf->getRecordCount() > 0) {
             foreach ($uelf as $ue_obj) {
                 Debug::text('User Expense ID: ' . $ue_obj->getId(), __FILE__, __LINE__, __METHOD__, 10);
                 $global_id = 'E' . $ue_obj->getId();
                 $deduction_order_arr[$global_id] = $this->getDeductionObjectArrayForSorting($ue_obj);
                 $dependency_tree->addNode($global_id, $deduction_order_arr[$global_id]['require_accounts'], $deduction_order_arr[$global_id]['affect_accounts'], $deduction_order_arr[$global_id]['order']);
             }
         }
     }
     unset($uef, $ue_obj);
     $profiler->startTimer('Calculate Dependency Tree');
     $sorted_deduction_ids = $dependency_tree->getAllNodesInOrder();
     $profiler->stopTimer('Calculate Dependency Tree');
     if (is_array($sorted_deduction_ids)) {
         foreach ($sorted_deduction_ids as $tmp => $deduction_id) {
             $retarr[$deduction_id] = $deduction_order_arr[$deduction_id];
         }
     }
     //Debug::Arr($retarr, 'AFTER - Deduction Order Array: ', __FILE__, __LINE__, __METHOD__,10);
     if (isset($retarr)) {
         return $retarr;
     }
     return FALSE;
 }