function showCustomFields($categoryId) { $sql = "SELECT * FROM " . TB_PREFIX . "customFields WHERE categorieID = :category"; $sth = dbQuery($sql, ':category', $categoryId); while ($field = $sth->fetch()) { $plugin = getPluginById($field['pluginId']); $plugin->printInputField($field['id']); } }
/** * Smarty {config_load} function plugin * * </pre> * @param Smarty */ function smarty_function_showCustomFields($params, &$smarty) { echo "<input type='hidden' name='categorie' value='{$params['categorieId']}'>"; $sql = "SELECT * FROM " . TB_PREFIX . "customFields WHERE categorieID = :id"; $sth = dbQuery($sql, ':id', $params['categorieId']); while ($field = $sth->fetch()) { $plugin = getPluginById($field['pluginId']); error_log($field['id'] . " " . $params['itemId'] . "sss"); $plugin->printInputField($field['id'], $params['itemId']); } }
function convertInitCustomFields() { // This function is exactly the same as convertCustomFields() in ./include/customFieldConversion.php but without the print_r and echo output while storing /* check if any value set -> keeps all data for sure */ global $dbh; $db = new db(); $sql = "SELECT * FROM " . TB_PREFIX . "custom_fields"; $sth = $dbh->prepare($sql); $sth->execute(); while ($custom = $sth->fetch()) { if (preg_match("/(.+)_cf([1-4])/", $custom['cf_custom_field'], $match)) { //print_r($match); switch ($match[1]) { case "biller": $cat = 1; break; case "customer": $cat = 2; break; case "product": $cat = 3; break; case "invoice": $cat = 4; break; default: $case = 0; } $cf_field = "custom_field" . $match[2]; if ($match[1] != "biller") { $sql = "SELECT id, :field FROM :table"; $tablename = TB_PREFIX . $match[1] . "s"; } else { $sql = "SELECT id, :field FROM :table"; $tablename = TB_PREFIX . $match[1]; } $store = false; /* * If custom field name is set */ if ($custom['cf_custom_label'] != NULL) { $store = true; } //error_log($sql); $tth = $dbh->prepare($sql); $tth->bindValue(':table', $tablename); $tth->bindValue(':field', $cf_field); $tth->execute(); /* * If any field is set, create custom field */ while ($res = $tth->fetch()) { if ($res[1] != NULL) { $store = true; break; } //echo($res[0]."<br />"); } if ($store) { // print_r($res); // echo "<br />".$sql." ".$res['id']; //create new text custom field saveInitCustomField(3, $cat, $custom['cf_custom_field'], $custom['cf_custom_label']); $id = lastInsertId(); error_log($id); $plugin = getPluginById(3); $plugin->setFieldId($id); //insert all data $uth = $dbh->prepare($sql); $uth->bindValue(':table', $tablename); $uth->bindValue(':field', $cf_field); $uth->execute(); while ($res2 = $uth->fetch()) { $plugin->saveInput($res2[$cf_field], $res2['id']); } } } } }