Example #1
0
 public function getEditorFields($table_name = null)
 {
     $sb = new StringBuf();
     $phValues = new _hx_array(array());
     $param = new haxe_ds_StringMap();
     $param->set("table", "fly_crm.editor_fields");
     $param->set("where", "field_cost|>-2" . _hx_string_or_null(Model_18($this, $param, $phValues, $sb, $table_name)));
     $param->set("fields", "field_name,field_label,field_type,field_options,table_name");
     $param->set("order", "table_name,field_rank,field_order");
     $param->set("limit", "100");
     $eFields = null;
     $a = $this->doSelect($param, $sb, $phValues);
     $eFields = new _hx_array($a);
     $ret = new haxe_ds_StringMap();
     $_g = 0;
     while ($_g < $eFields->length) {
         $ef = $eFields[$_g];
         ++$_g;
         $table = $ef["table_name"];
         if (!$ret->exists($table)) {
             $ret->set($table, new _hx_array(array()));
         }
         $a1 = $ret->get($table);
         $a1->push(php_Lib::hashOfAssociativeArray($ef));
         $ret->set($table, $a1);
         unset($table, $ef, $a1);
     }
     return $ret;
 }
Example #2
0
 public function alterColumns($columns)
 {
     $target = new haxe_ds_StringMap();
     $wfate = 0;
     if ($this->has_properties) {
         $target->set("@", $wfate);
         $wfate++;
     }
     $_g1 = 0;
     $_g = $columns->length;
     while ($_g1 < $_g) {
         $i = $_g1++;
         $col = $columns[$i];
         if ($col->prevName !== null) {
             $target->set($col->prevName, $wfate);
         }
         if ($col->name !== null) {
             $wfate++;
         }
         unset($i, $col);
     }
     $fate = new _hx_array(array());
     $_g11 = 0;
     $_g2 = $this->t->get_width();
     while ($_g11 < $_g2) {
         $i1 = $_g11++;
         $targeti = -1;
         $name = $this->t->getCell($i1, 0);
         if ($target->exists($name)) {
             $targeti = $target->get($name);
         }
         $fate->push($targeti);
         unset($targeti, $name, $i1);
     }
     $this->t->insertOrDeleteColumns($fate, $wfate);
     $start = null;
     if ($this->has_properties) {
         $start = 1;
     } else {
         $start = 0;
     }
     $at = $start;
     $_g12 = 0;
     $_g3 = $columns->length;
     while ($_g12 < $_g3) {
         $i2 = $_g12++;
         $col1 = $columns[$i2];
         if ($col1->name !== null) {
             if ($col1->name !== $col1->prevName) {
                 $this->t->setCell($at, 0, $col1->name);
             }
         }
         if ($col1->name !== null) {
             $at++;
         }
         unset($i2, $col1);
     }
     if (!$this->has_properties) {
         return true;
     }
     $this->colChange();
     $at = $start;
     $_g13 = 0;
     $_g4 = $columns->length;
     while ($_g13 < $_g4) {
         $i3 = $_g13++;
         $col2 = $columns[$i3];
         if ($col2->name !== null) {
             $_g21 = 0;
             $_g31 = $col2->props;
             while ($_g21 < $_g31->length) {
                 $prop = $_g31[$_g21];
                 ++$_g21;
                 $this->setCell($col2->name, $prop->name, $prop->val);
                 unset($prop);
             }
             unset($_g31, $_g21);
         }
         if ($col2->name !== null) {
             $at++;
         }
         unset($i3, $col2);
     }
     return true;
 }
Example #3
0
 public function apply()
 {
     if ($this->db === null) {
         return null;
     }
     if ($this->align === null) {
         $this->align = new coopy_Alignment();
     }
     if (!$this->validateSchema()) {
         return null;
     }
     $rowid_name = $this->db->rowid();
     $key_cols = new _hx_array(array());
     $data_cols = new _hx_array(array());
     $all_cols = new _hx_array(array());
     $all_cols1 = new _hx_array(array());
     $all_cols2 = new _hx_array(array());
     $all_cols3 = new _hx_array(array());
     $common = $this->local;
     if ($this->local !== null) {
         $key_cols = $this->local->getPrimaryKey();
         $data_cols = $this->local->getAllButPrimaryKey();
         $all_cols = $this->local->getColumnNames();
         $all_cols1 = $this->local->getColumnNames();
     }
     if ($this->remote !== null) {
         $all_cols2 = $this->remote->getColumnNames();
         if ($common === null) {
             $common = $this->remote;
         }
     }
     if ($this->alt !== null) {
         $all_cols3 = $this->alt->getColumnNames();
         if ($common === null) {
             $common = $this->alt;
         }
     } else {
         $all_cols3 = $all_cols2;
     }
     $all_common_cols = new _hx_array(array());
     $data_common_cols = new _hx_array(array());
     $present1 = new haxe_ds_StringMap();
     $present2 = new haxe_ds_StringMap();
     $present3 = new haxe_ds_StringMap();
     $present_primary = new haxe_ds_StringMap();
     $has_column_add = false;
     $_g1 = 0;
     $_g = $key_cols->length;
     while ($_g1 < $_g) {
         $i = $_g1++;
         $present_primary->set($key_cols[$i], $i);
         unset($i);
     }
     $_g11 = 0;
     $_g2 = $all_cols1->length;
     while ($_g11 < $_g2) {
         $i1 = $_g11++;
         $key = $all_cols1[$i1];
         $present1->set($key, $i1);
         unset($key, $i1);
     }
     $_g12 = 0;
     $_g3 = $all_cols2->length;
     while ($_g12 < $_g3) {
         $i2 = $_g12++;
         $key1 = $all_cols2[$i2];
         if (!$present1->exists($key1)) {
             $has_column_add = true;
         }
         $present2->set($key1, $i2);
         unset($key1, $i2);
     }
     $_g13 = 0;
     $_g4 = $all_cols3->length;
     while ($_g13 < $_g4) {
         $i3 = $_g13++;
         $key2 = $all_cols3[$i3];
         if (!$present1->exists($key2)) {
             $has_column_add = true;
         }
         $present3->set($key2, $i3);
         if ($present1->exists($key2)) {
             if ($present2->exists($key2)) {
                 $all_common_cols->push($key2);
                 if (!$present_primary->exists($key2)) {
                     $data_common_cols->push($key2);
                 }
             }
         }
         unset($key2, $i3);
     }
     $this->align->meta = new coopy_Alignment();
     $_g14 = 0;
     $_g5 = $all_cols1->length;
     while ($_g14 < $_g5) {
         $i4 = $_g14++;
         $key3 = $all_cols1[$i4];
         if ($present2->exists($key3)) {
             $this->align->meta->link($i4, $present2->get($key3));
         } else {
             $this->align->meta->link($i4, -1);
         }
         unset($key3, $i4);
     }
     $_g15 = 0;
     $_g6 = $all_cols2->length;
     while ($_g15 < $_g6) {
         $i5 = $_g15++;
         $key4 = $all_cols2[$i5];
         if (!$present1->exists($key4)) {
             $this->align->meta->link(-1, $i5);
         }
         unset($key4, $i5);
     }
     $this->scanColumns($all_cols1, $all_cols2, $key_cols, $present1, $present2, $this->align);
     $this->align->tables($this->local, $this->remote);
     if ($this->alt !== null) {
         $this->scanColumns($all_cols1, $all_cols3, $key_cols, $present1, $present3, $this->align->reference);
         $this->align->reference->tables($this->local, $this->alt);
     }
     $sql_table1 = "";
     $sql_table2 = "";
     $sql_table3 = "";
     if ($this->local !== null) {
         $sql_table1 = $this->local->getQuotedTableName();
     }
     if ($this->remote !== null) {
         $sql_table2 = $this->remote->getQuotedTableName();
     }
     if ($this->alt !== null) {
         $sql_table3 = $this->alt->getQuotedTableName();
     }
     if ($this->peered) {
         $sql_table1 = "main." . _hx_string_or_null($sql_table1);
         $sql_table2 = "__peer__." . _hx_string_or_null($sql_table2);
     }
     if ($this->alt_peered) {
         $sql_table2 = "__alt__." . _hx_string_or_null($sql_table3);
     }
     $sql_key_cols = "";
     $_g16 = 0;
     $_g7 = $key_cols->length;
     while ($_g16 < $_g7) {
         $i6 = $_g16++;
         if ($i6 > 0) {
             $sql_key_cols .= ",";
         }
         $sql_key_cols .= _hx_string_or_null($common->getQuotedColumnName($key_cols[$i6]));
         unset($i6);
     }
     $sql_all_cols = "";
     $_g17 = 0;
     $_g8 = $all_common_cols->length;
     while ($_g17 < $_g8) {
         $i7 = $_g17++;
         if ($i7 > 0) {
             $sql_all_cols .= ",";
         }
         $sql_all_cols .= _hx_string_or_null($common->getQuotedColumnName($all_common_cols[$i7]));
         unset($i7);
     }
     $sql_all_cols1 = "";
     $_g18 = 0;
     $_g9 = $all_cols1->length;
     while ($_g18 < $_g9) {
         $i8 = $_g18++;
         if ($i8 > 0) {
             $sql_all_cols1 .= ",";
         }
         $sql_all_cols1 .= _hx_string_or_null($this->local->getQuotedColumnName($all_cols1[$i8]));
         unset($i8);
     }
     $sql_all_cols2 = "";
     $_g19 = 0;
     $_g10 = $all_cols2->length;
     while ($_g19 < $_g10) {
         $i9 = $_g19++;
         if ($i9 > 0) {
             $sql_all_cols2 .= ",";
         }
         $sql_all_cols2 .= _hx_string_or_null($this->remote->getQuotedColumnName($all_cols2[$i9]));
         unset($i9);
     }
     $sql_all_cols3 = "";
     if ($this->alt !== null) {
         $_g110 = 0;
         $_g20 = $all_cols3->length;
         while ($_g110 < $_g20) {
             $i10 = $_g110++;
             if ($i10 > 0) {
                 $sql_all_cols3 .= ",";
             }
             $sql_all_cols3 .= _hx_string_or_null($this->alt->getQuotedColumnName($all_cols3[$i10]));
             unset($i10);
         }
     }
     $sql_key_match2 = "";
     $_g111 = 0;
     $_g21 = $key_cols->length;
     while ($_g111 < $_g21) {
         $i11 = $_g111++;
         if ($i11 > 0) {
             $sql_key_match2 .= " AND ";
         }
         $n = $common->getQuotedColumnName($key_cols[$i11]);
         $sql_key_match2 .= _hx_string_or_null($sql_table1) . "." . _hx_string_or_null($n) . " IS " . _hx_string_or_null($sql_table2) . "." . _hx_string_or_null($n);
         unset($n, $i11);
     }
     $sql_key_match3 = "";
     if ($this->alt !== null) {
         $_g112 = 0;
         $_g22 = $key_cols->length;
         while ($_g112 < $_g22) {
             $i12 = $_g112++;
             if ($i12 > 0) {
                 $sql_key_match3 .= " AND ";
             }
             $n1 = $common->getQuotedColumnName($key_cols[$i12]);
             $sql_key_match3 .= _hx_string_or_null($sql_table1) . "." . _hx_string_or_null($n1) . " IS " . _hx_string_or_null($sql_table3) . "." . _hx_string_or_null($n1);
             unset($n1, $i12);
         }
     }
     $sql_data_mismatch = "";
     $_g113 = 0;
     $_g23 = $data_common_cols->length;
     while ($_g113 < $_g23) {
         $i13 = $_g113++;
         if ($i13 > 0) {
             $sql_data_mismatch .= " OR ";
         }
         $n2 = $common->getQuotedColumnName($data_common_cols[$i13]);
         $sql_data_mismatch .= _hx_string_or_null($sql_table1) . "." . _hx_string_or_null($n2) . " IS NOT " . _hx_string_or_null($sql_table2) . "." . _hx_string_or_null($n2);
         unset($n2, $i13);
     }
     $_g114 = 0;
     $_g24 = $all_cols2->length;
     while ($_g114 < $_g24) {
         $i14 = $_g114++;
         $key5 = $all_cols2[$i14];
         if (!$present1->exists($key5)) {
             if ($sql_data_mismatch !== "") {
                 $sql_data_mismatch .= " OR ";
             }
             $n3 = $common->getQuotedColumnName($key5);
             $sql_data_mismatch .= _hx_string_or_null($sql_table2) . "." . _hx_string_or_null($n3) . " IS NOT NULL";
             unset($n3);
         }
         unset($key5, $i14);
     }
     if ($this->alt !== null) {
         $_g115 = 0;
         $_g25 = $data_common_cols->length;
         while ($_g115 < $_g25) {
             $i15 = $_g115++;
             if (strlen($sql_data_mismatch) > 0) {
                 $sql_data_mismatch .= " OR ";
             }
             $n4 = $common->getQuotedColumnName($data_common_cols[$i15]);
             $sql_data_mismatch .= _hx_string_or_null($sql_table1) . "." . _hx_string_or_null($n4) . " IS NOT " . _hx_string_or_null($sql_table3) . "." . _hx_string_or_null($n4);
             unset($n4, $i15);
         }
         $_g116 = 0;
         $_g26 = $all_cols3->length;
         while ($_g116 < $_g26) {
             $i16 = $_g116++;
             $key6 = $all_cols3[$i16];
             if (!$present1->exists($key6)) {
                 if ($sql_data_mismatch !== "") {
                     $sql_data_mismatch .= " OR ";
                 }
                 $n5 = $common->getQuotedColumnName($key6);
                 $sql_data_mismatch .= _hx_string_or_null($sql_table3) . "." . _hx_string_or_null($n5) . " IS NOT NULL";
                 unset($n5);
             }
             unset($key6, $i16);
         }
     }
     $sql_dbl_cols = "";
     $dbl_cols = new _hx_array(array());
     $_g117 = 0;
     $_g27 = $all_cols1->length;
     while ($_g117 < $_g27) {
         $i17 = $_g117++;
         if ($sql_dbl_cols !== "") {
             $sql_dbl_cols .= ",";
         }
         $buf = "__coopy_" . _hx_string_rec($i17, "");
         $n6 = $common->getQuotedColumnName($all_cols1[$i17]);
         $sql_dbl_cols .= _hx_string_or_null($sql_table1) . "." . _hx_string_or_null($n6) . " AS " . _hx_string_or_null($buf);
         $dbl_cols->push($buf);
         unset($n6, $i17, $buf);
     }
     $_g118 = 0;
     $_g28 = $all_cols2->length;
     while ($_g118 < $_g28) {
         $i18 = $_g118++;
         if ($sql_dbl_cols !== "") {
             $sql_dbl_cols .= ",";
         }
         $buf1 = "__coopy_" . _hx_string_rec($i18, "") . "b";
         $n7 = $common->getQuotedColumnName($all_cols2[$i18]);
         $sql_dbl_cols .= _hx_string_or_null($sql_table2) . "." . _hx_string_or_null($n7) . " AS " . _hx_string_or_null($buf1);
         $dbl_cols->push($buf1);
         unset($n7, $i18, $buf1);
     }
     if ($this->alt !== null) {
         $_g119 = 0;
         $_g29 = $all_cols3->length;
         while ($_g119 < $_g29) {
             $i19 = $_g119++;
             if ($sql_dbl_cols !== "") {
                 $sql_dbl_cols .= ",";
             }
             $buf2 = "__coopy_" . _hx_string_rec($i19, "") . "c";
             $n8 = $common->getQuotedColumnName($all_cols3[$i19]);
             $sql_dbl_cols .= _hx_string_or_null($sql_table3) . "." . _hx_string_or_null($n8) . " AS " . _hx_string_or_null($buf2);
             $dbl_cols->push($buf2);
             unset($n8, $i19, $buf2);
         }
     }
     $sql_order = "";
     $_g120 = 0;
     $_g30 = $key_cols->length;
     while ($_g120 < $_g30) {
         $i20 = $_g120++;
         if ($i20 > 0) {
             $sql_order .= ",";
         }
         $n9 = $common->getQuotedColumnName($key_cols[$i20]);
         $sql_order .= _hx_string_or_null($n9);
         unset($n9, $i20);
     }
     $rowid = "-3";
     $rowid1 = "-3";
     $rowid2 = "-3";
     $rowid3 = "-3";
     if ($rowid_name !== null) {
         $rowid = $rowid_name;
         if ($this->local !== null) {
             $rowid1 = _hx_string_or_null($sql_table1) . "." . _hx_string_or_null($rowid_name);
         }
         if ($this->remote !== null) {
             $rowid2 = _hx_string_or_null($sql_table2) . "." . _hx_string_or_null($rowid_name);
         }
         if ($this->alt !== null) {
             $rowid3 = _hx_string_or_null($sql_table3) . "." . _hx_string_or_null($rowid_name);
         }
     }
     $this->at0 = 1;
     $this->at1 = 1;
     $this->at2 = 1;
     $this->diff_ct = 0;
     if ($this->remote !== null) {
         $sql_inserts = "SELECT DISTINCT 0 AS __coopy_code, NULL, " . _hx_string_or_null($rowid) . " AS rowid, NULL, " . _hx_string_or_null($sql_all_cols2) . " FROM " . _hx_string_or_null($sql_table2);
         if ($this->local !== null) {
             $sql_inserts .= " WHERE NOT EXISTS (SELECT 1 FROM " . _hx_string_or_null($sql_table1) . _hx_string_or_null($this->where($sql_key_match2)) . ")";
         }
         $sql_inserts_order = _hx_deref(new _hx_array(array("__coopy_code", "NULL", "rowid", "NULL")))->concat($all_cols2);
         $this->linkQuery($sql_inserts, $sql_inserts_order);
     }
     if ($this->alt !== null) {
         $sql_inserts1 = "SELECT DISTINCT 1 AS __coopy_code, NULL, NULL, " . _hx_string_or_null($rowid) . " AS rowid, " . _hx_string_or_null($sql_all_cols3) . " FROM " . _hx_string_or_null($sql_table3);
         if ($this->local !== null) {
             $sql_inserts1 .= " WHERE NOT EXISTS (SELECT 1 FROM " . _hx_string_or_null($sql_table1) . _hx_string_or_null($this->where($sql_key_match3)) . ")";
         }
         $sql_inserts_order1 = _hx_deref(new _hx_array(array("__coopy_code", "NULL", "NULL", "rowid")))->concat($all_cols3);
         $this->linkQuery($sql_inserts1, $sql_inserts_order1);
     }
     if ($this->local !== null && $this->remote !== null) {
         $sql_updates = "SELECT DISTINCT 2 AS __coopy_code, " . _hx_string_or_null($rowid1) . " AS __coopy_rowid0, " . _hx_string_or_null($rowid2) . " AS __coopy_rowid1, ";
         if ($this->alt !== null) {
             $sql_updates .= _hx_string_or_null($rowid3) . " AS __coopy_rowid2,";
         } else {
             $sql_updates .= " NULL,";
         }
         $sql_updates .= _hx_string_or_null($sql_dbl_cols) . " FROM " . _hx_string_or_null($sql_table1);
         if ($sql_table1 !== $sql_table2) {
             $sql_updates .= " INNER JOIN " . _hx_string_or_null($sql_table2) . " ON " . _hx_string_or_null($sql_key_match2);
         }
         if ($this->alt !== null && $sql_table1 !== $sql_table3) {
             $sql_updates .= " INNER JOIN " . _hx_string_or_null($sql_table3) . " ON " . _hx_string_or_null($sql_key_match3);
         }
         $sql_updates .= _hx_string_or_null($this->where($sql_data_mismatch));
         $sql_updates_order = _hx_deref(new _hx_array(array("__coopy_code", "__coopy_rowid0", "__coopy_rowid1", "__coopy_rowid2")))->concat($dbl_cols);
         $this->linkQuery($sql_updates, $sql_updates_order);
     }
     if ($this->alt === null) {
         if ($this->local !== null) {
             $sql_deletes = "SELECT DISTINCT 0 AS __coopy_code, " . _hx_string_or_null($rowid) . " AS rowid, NULL, NULL, " . _hx_string_or_null($sql_all_cols1) . " FROM " . _hx_string_or_null($sql_table1);
             if ($this->remote !== null) {
                 $sql_deletes .= " WHERE NOT EXISTS (SELECT 1 FROM " . _hx_string_or_null($sql_table2) . _hx_string_or_null($this->where($sql_key_match2)) . ")";
             }
             $sql_deletes_order = _hx_deref(new _hx_array(array("__coopy_code", "rowid", "NULL", "NULL")))->concat($all_cols1);
             $this->linkQuery($sql_deletes, $sql_deletes_order);
         }
     }
     if ($this->alt !== null) {
         $sql_deletes1 = "SELECT 2 AS __coopy_code, " . _hx_string_or_null($rowid1) . " AS __coopy_rowid0, " . _hx_string_or_null($rowid2) . " AS __coopy_rowid1, ";
         $sql_deletes1 .= _hx_string_or_null($rowid3) . " AS __coopy_rowid2, ";
         $sql_deletes1 .= _hx_string_or_null($sql_dbl_cols);
         $sql_deletes1 .= " FROM " . _hx_string_or_null($sql_table1);
         if ($this->remote !== null) {
             $sql_deletes1 .= " LEFT OUTER JOIN " . _hx_string_or_null($sql_table2) . " ON " . _hx_string_or_null($sql_key_match2);
         }
         $sql_deletes1 .= " LEFT OUTER JOIN " . _hx_string_or_null($sql_table3) . " ON " . _hx_string_or_null($sql_key_match3);
         $sql_deletes1 .= " WHERE __coopy_rowid1 IS NULL OR __coopy_rowid2 IS NULL";
         $sql_deletes_order1 = _hx_deref(new _hx_array(array("__coopy_code", "__coopy_rowid0", "__coopy_rowid1", "__coopy_rowid2")))->concat($dbl_cols);
         $this->linkQuery($sql_deletes1, $sql_deletes_order1);
     }
     if ($this->diff_ct === 0) {
         $this->align->markIdentical();
     }
     return $this->align;
 }
 public function alignColumns($align, $a, $b)
 {
     $align->range($a->get_width(), $b->get_width());
     $align->tables($a, $b);
     $align->setRowlike(false);
     $slop = 5;
     $va = $a->getCellView();
     $vb = $b->getCellView();
     $ra_best = 0;
     $rb_best = 0;
     $ct_best = -1;
     $ma_best = null;
     $mb_best = null;
     $ra_header = 0;
     $rb_header = 0;
     $ra_uniques = 0;
     $rb_uniques = 0;
     $_g = 0;
     while ($_g < $slop) {
         $ra = $_g++;
         $_g1 = 0;
         while ($_g1 < $slop) {
             $rb = $_g1++;
             $ma = new haxe_ds_StringMap();
             $mb = new haxe_ds_StringMap();
             $ct = 0;
             $uniques = 0;
             if ($ra < $a->get_height()) {
                 $_g3 = 0;
                 $_g2 = $a->get_width();
                 while ($_g3 < $_g2) {
                     $ca = $_g3++;
                     $key = $va->toString($a->getCell($ca, $ra));
                     if ($ma->exists($key)) {
                         $ma->set($key, -1);
                         $uniques--;
                     } else {
                         $ma->set($key, $ca);
                         $uniques++;
                     }
                     unset($key, $ca);
                 }
                 unset($_g3, $_g2);
                 if ($uniques > $ra_uniques) {
                     $ra_header = $ra;
                     $ra_uniques = $uniques;
                 }
             }
             $uniques = 0;
             if ($rb < $b->get_height()) {
                 $_g31 = 0;
                 $_g21 = $b->get_width();
                 while ($_g31 < $_g21) {
                     $cb = $_g31++;
                     $key1 = $vb->toString($b->getCell($cb, $rb));
                     if ($mb->exists($key1)) {
                         $mb->set($key1, -1);
                         $uniques--;
                     } else {
                         $mb->set($key1, $cb);
                         $uniques++;
                     }
                     unset($key1, $cb);
                 }
                 unset($_g31, $_g21);
                 if ($uniques > $rb_uniques) {
                     $rb_header = $rb;
                     $rb_uniques = $uniques;
                 }
             }
             if (null == $ma) {
                 throw new HException('null iterable');
             }
             $__hx__it = $ma->keys();
             while ($__hx__it->hasNext()) {
                 unset($key2);
                 $key2 = $__hx__it->next();
                 $i0 = $ma->get($key2);
                 $i1 = $mb->get($key2);
                 if ($i1 !== null) {
                     if ($i1 >= 0 && $i0 >= 0) {
                         $ct++;
                     }
                 }
                 unset($i1, $i0);
             }
             if ($ct > $ct_best) {
                 $ct_best = $ct;
                 $ma_best = $ma;
                 $mb_best = $mb;
                 $ra_best = $ra;
                 $rb_best = $rb;
             }
             unset($uniques, $rb, $mb, $ma, $ct);
         }
         unset($_g1);
         unset($ra);
     }
     if ($ma_best === null) {
         if ($a->get_height() > 0 && $b->get_height() === 0) {
             $align->headers(0, -1);
         } else {
             if ($a->get_height() === 0 && $b->get_height() > 0) {
                 $align->headers(-1, 0);
             }
         }
         return;
     }
     if (null == $ma_best) {
         throw new HException('null iterable');
     }
     $__hx__it = $ma_best->keys();
     while ($__hx__it->hasNext()) {
         unset($key3);
         $key3 = $__hx__it->next();
         $i01 = $ma_best->get($key3);
         $i11 = $mb_best->get($key3);
         if ($i01 !== null && $i11 !== null) {
             $align->link($i01, $i11);
         } else {
             if ($i01 !== null) {
                 $align->link($i01, -1);
             } else {
                 if ($i11 !== null) {
                     $align->link(-1, $i11);
                 }
             }
         }
         unset($i11, $i01);
     }
     if (null == $mb_best) {
         throw new HException('null iterable');
     }
     $__hx__it = $mb_best->keys();
     while ($__hx__it->hasNext()) {
         unset($key4);
         $key4 = $__hx__it->next();
         $i02 = $ma_best->get($key4);
         $i12 = $mb_best->get($key4);
         if ($i02 === null && $i12 !== null) {
             $align->link(-1, $i12);
         }
         unset($i12, $i02);
     }
     $align->headers($ra_header, $rb_header);
 }
Example #5
0
 public function edit($param)
 {
     $fieldNames = new haxe_ds_StringMap();
     $typeMap = null;
     $typeMap = model_Clients_5($this, $fieldNames, $param, $typeMap);
     $optionsMap = new haxe_ds_StringMap();
     $eF = $this->getEditorFields(null);
     $keys = $eF->keys();
     $tableNames = new _hx_array(array());
     $tableFields = new haxe_ds_StringMap();
     haxe_Log::trace($param, _hx_anonymous(array("fileName" => "Clients.hx", "lineNumber" => 139, "className" => "model.Clients", "methodName" => "edit")));
     while ($keys->hasNext()) {
         $k = $keys->next();
         $tableNames->push($k);
         $aFields = $eF->get($k);
         $cFields = $aFields->map(array(new _hx_lambda(array(&$aFields, &$eF, &$fieldNames, &$k, &$keys, &$optionsMap, &$param, &$tableFields, &$tableNames, &$typeMap), "model_Clients_6"), 'execute'));
         $tableFields->set($k, $cFields);
         $_g2 = 0;
         $_g1 = $cFields->length;
         while ($_g2 < $_g1) {
             $f = $_g2++;
             $fieldNames->set($cFields[$f], _hx_array_get($aFields, $f)->get("field_name"));
             if (_hx_array_get($aFields, $f)->get("field_options") !== null) {
                 $optionsMap->set($cFields[$f], _hx_array_get($aFields, $f)->get("field_options"));
             }
             $typeMap->set($cFields[$f], _hx_array_get($aFields, $f)->get("field_type"));
             unset($f);
         }
         unset($_g2, $_g1);
         unset($k, $cFields, $aFields);
     }
     haxe_Log::trace($tableNames, _hx_anonymous(array("fileName" => "Clients.hx", "lineNumber" => 158, "className" => "model.Clients", "methodName" => "edit")));
     $editTables = new haxe_ds_StringMap();
     $ti = 0;
     $tableNames->remove("vicidial_list");
     $tableNames->push("buchungs_anforderungen");
     $_g11 = 0;
     while ($_g11 < $tableNames->length) {
         $table = $tableNames[$_g11];
         ++$_g11;
         $p = new haxe_ds_StringMap();
         $sb = new StringBuf();
         $phValues = new _hx_array(array());
         $p->set("primary_id", $param->get("primary_id"));
         switch ($table) {
             case "clients":
                 $p->set("table", "vicidial_list");
                 $p->set("jointable", "fly_crm." . _hx_string_or_null($table));
                 $p->set("joincond", $param->get("joincond"));
                 $p->set("fields", Std::string(_hx_string_call($param->get("fields"), "split", array(","))->map(array(new _hx_lambda(array(&$_g11, &$eF, &$editTables, &$fieldNames, &$keys, &$optionsMap, &$p, &$param, &$phValues, &$sb, &$table, &$tableFields, &$tableNames, &$ti, &$typeMap), "model_Clients_7"), 'execute'))->join(",")) . "," . _hx_string_or_null($tableFields->get($table)->map(array(new _hx_lambda(array(&$_g11, &$eF, &$editTables, &$fieldNames, &$keys, &$optionsMap, &$p, &$param, &$phValues, &$sb, &$table, &$tableFields, &$tableNames, &$ti, &$typeMap), "model_Clients_8"), 'execute'))->join(",")));
                 $p->set("where", "vicidial_list.lead_id|" . Std::string($param->get("lead_id")));
                 $editTables->set($table, php_Lib::hashOfAssociativeArray($this->doJoin($p, $sb, $phValues)));
                 break;
             case "buchungs_anforderungen":
                 $p->set("table", "fly_crm." . _hx_string_or_null($table));
                 $p->set("fields", model_Clients::$pay_history_fields->map(array(new _hx_lambda(array(&$_g11, &$eF, &$editTables, &$fieldNames, &$keys, &$optionsMap, &$p, &$param, &$phValues, &$sb, &$table, &$tableFields, &$tableNames, &$ti, &$typeMap), "model_Clients_9"), 'execute'))->join(","));
                 $p->set("where", "`Mandat-ID`|" . Std::string($param->get("client_id")) . "K1");
                 $editTables->set("pay_history", php_Lib::hashOfAssociativeArray($this->doSelect($p, $sb, $phValues)));
                 break;
             default:
                 $p->set("table", model_Clients_10($this, $_g11, $eF, $editTables, $fieldNames, $keys, $optionsMap, $p, $param, $phValues, $sb, $table, $tableFields, $tableNames, $ti, $typeMap));
                 $p->set("fields", $tableFields->get($table)->join(","));
                 if ($table === "vicidial_list") {
                     $p->set("where", "vendor_lead_code|" . Std::string($param->get("client_id")));
                 } else {
                     $p->set("where", "client_id|" . Std::string($param->get("client_id")));
                 }
                 $editTables->set($table, php_Lib::hashOfAssociativeArray($this->doSelect($p, $sb, $phValues)));
                 if ($table === "pay_source") {
                     haxe_Log::trace($tableFields->get($table), _hx_anonymous(array("fileName" => "Clients.hx", "lineNumber" => 198, "className" => "model.Clients", "methodName" => "edit")));
                 }
                 break;
         }
         unset($table, $sb, $phValues, $p);
     }
     $recordings = $this->getRecordings(Std::parseInt($param->get("lead_id")));
     $editTables->set("konto_auszug", php_Lib::hashOfAssociativeArray(_hx_deref(new model_ClientHistory(null))->findClient(model_Clients_11($this, $eF, $editTables, $fieldNames, $keys, $optionsMap, $param, $recordings, $tableFields, $tableNames, $ti, $typeMap), true)));
     $this->data = _hx_anonymous(array("fieldNames" => php_Lib::associativeArrayOfHash($fieldNames), "editData" => php_Lib::associativeArrayOfHash($editTables), "typeMap" => php_Lib::associativeArrayOfHash($typeMap), "optionsMap" => php_Lib::associativeArrayOfHash($optionsMap), "recordings" => $recordings));
     $userMap = new haxe_ds_StringMap();
     $sb1 = new StringBuf();
     $phValues1 = new _hx_array(array());
     $p1 = new haxe_ds_StringMap();
     $p1->set("table", "vicidial_users");
     $p1->set("fields", "user,full_name");
     $p1->set("where", "user_group|AGENTS_A");
     $owner = Std::parseInt(model_Clients_12($this, $eF, $editTables, $fieldNames, $keys, $optionsMap, $p1, $param, $phValues1, $recordings, $sb1, $tableFields, $tableNames, $ti, $typeMap, $userMap));
     haxe_Log::trace($owner, _hx_anonymous(array("fileName" => "Clients.hx", "lineNumber" => 218, "className" => "model.Clients", "methodName" => "edit")));
     $this->data->userMap = _hx_deref(new model_Users(null))->get_info(null);
     return $this->json_encode();
 }