コード例 #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 testTwoTrees_2()
 {
     $deptree = new DependencyTree();
     $deptree->setTreeOrdering(FALSE);
     //
     //U4452 should be above U149 always!!
     //
     //Tree 1
     $deptree->addNode('U156', array(254), array(254), 40);
     $deptree->addNode('U149', array(254, 255), array(110), 50);
     $deptree->addNode('U153', array(254), array(115), 60);
     $deptree->addNode('U4452', array(254), array(255), 60);
     //Fails if I put it here
     $deptree->addNode('U998', array(254), array(127), 50);
     //Tree 2
     $deptree->addNode('Z156', array(2540), array(2540), 40);
     $deptree->addNode('Z149', array(2540, 2550), array(1100), 50);
     $deptree->addNode('Z153', array(2540), array(1150), 60);
     $deptree->addNode('Z4452', array(2540), array(2550), 60);
     //Fails if I put it here
     $deptree->addNode('Z998', array(2540), array(1270), 50);
     $result = $deptree->_buildTree();
     //var_dump($result);
     $should_match = array(0 => 'U156', 1 => 'U4452', 2 => 'U149', 3 => 'U153', 4 => 'U998');
     //Tree 1
     $test1 = $this->indexOf('U156', $result) < $this->indexOf('U998', $result) ? TRUE : FALSE;
     $this->assertEquals($test1, TRUE);
     $test1 = $this->indexOf('U998', $result) < $this->indexOf('U153', $result) ? TRUE : FALSE;
     $this->assertEquals($test1, TRUE);
     $test1 = $this->indexOf('U153', $result) < $this->indexOf('U4452', $result) ? TRUE : FALSE;
     $this->assertEquals($test1, TRUE);
     $test1 = $this->indexOf('U4452', $result) < $this->indexOf('U149', $result) ? TRUE : FALSE;
     $this->assertEquals($test1, TRUE);
     //Tree 2
     $test1 = $this->indexOf('Z156', $result) < $this->indexOf('Z998', $result) ? TRUE : FALSE;
     $this->assertEquals($test1, TRUE);
     $test1 = $this->indexOf('Z998', $result) < $this->indexOf('Z153', $result) ? TRUE : FALSE;
     $this->assertEquals($test1, TRUE);
     $test1 = $this->indexOf('Z153', $result) < $this->indexOf('Z4452', $result) ? TRUE : FALSE;
     $this->assertEquals($test1, TRUE);
     $test1 = $this->indexOf('Z4452', $result) < $this->indexOf('Z149', $result) ? TRUE : FALSE;
     $this->assertEquals($test1, TRUE);
     //Combined Trees
     $test1 = $this->indexOf('U156', $result) < $this->indexOf('Z156', $result) ? TRUE : FALSE;
     $this->assertEquals($test1, TRUE);
     $test1 = $this->indexOf('U998', $result) < $this->indexOf('Z153', $result) ? TRUE : FALSE;
     $this->assertEquals($test1, TRUE);
     $test1 = $this->indexOf('U153', $result) < $this->indexOf('Z4452', $result) ? TRUE : FALSE;
     $this->assertEquals($test1, TRUE);
     $test1 = $this->indexOf('U4452', $result) < $this->indexOf('Z149', $result) ? TRUE : FALSE;
     $this->assertEquals($test1, TRUE);
 }
コード例 #3
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;
 }