Exemple #1
0
 /**
  * @param string $xml xml data of the tracking
  * @return string Return the database dump
  * @soapmethod
  */
 public function syncTrackingTable($xml)
 {
     $doc = new TXmlDocument('1.0', 'utf-8');
     $doc->loadFromString($xml);
     // mains tracking table
     $tableArray["hr_tracking"] = array();
     $tableArray["hr_alarms"] = array();
     $nreOfRecord = 0;
     $ids = '';
     if ("trackingDump" == $doc->getTagName()) {
         if ($doc->getHasElement()) {
             if ($doc->getElements()->itemAt(0)->getHasElement()) {
                 $tables = $doc->getElements()->itemAt(0)->getElements();
                 $tablesName = "";
                 foreach ($tables as $table) {
                     if ($table->getHasElement()) {
                         $tableName = $table->getTagName();
                         $records = $table->getElements()->itemAt(0)->getElements();
                         foreach ($records as $record) {
                             if ($record->getHasElement()) {
                                 $fields = $record->getElements();
                                 $recordArray = array();
                                 foreach ($fields as $field) {
                                     $fieldName = $field->getTagName();
                                     $fieldValue = $field->getValue();
                                     $recordArray[$fieldName] = $fieldValue;
                                 }
                                 $tableArray[$tableName][] = $recordArray;
                             }
                         }
                     }
                 }
                 $ids .= $this->syncAlarm($tableArray["hr_alarms"]);
                 if ($ids != "") {
                     $ids .= ",";
                 }
                 $ids .= $this->syncTracking($tableArray);
                 return $ids;
             } else {
                 return "0";
             }
         } else {
             return "0";
         }
     } else {
         return "0";
     }
 }