/** * edit person weight for service group (for auto planning?) * @param array $params */ function churchservice_editServiceGroupPersonWeight($params) { $i = new CTInterface(); $i->setParam("servicegroup_id"); $i->setParam("person_id"); $i->setParam("max_per_month"); $i->setParam("relation_weight"); $i->setParam("morning_weight"); $i->addModifiedParams(); try { db_insert("cs_servicegroup_person_weight")->fields($i->getDBInsertArrayFromParams($params))->execute(false); } catch (Exception $e) { db_query("UPDATE {cs_servicegroup_person_weight} \n SET max_per_month=:max_per_month, relation_weight=:relation_weight, morning_weight=:morning_weight\n WHERE servicegroup_id=:servicegroup_id and person_id=:person_id", $i->getDBParamsArrayFromParams($params)); } }