Re: Print data from mash subform
Posted: Thu Nov 01, 2012 6:18 am
Code: Select all
/* Create a temp table with all appointments NOT-CLOSED and add a column with technician names */
$sql = "CREATE TABLE #browseTable#";
$sql .= " SELECT * FROM appointment INNER JOIN (request, appointment_status, client)";
$sql .= " ON (app_req_id = req_id AND app_aps_id = aps_id AND req_cli_id = cli_id)";
$sql .= " WHERE app_aps_id <> '1504808820c931' AND app_aps_id <> '1504808787a1a9'";
nuDebug('run1-> '.$sql);
nuRunQuery($sql);
/* Add a column to temp table*/
$sql = "ALTER TABLE #browseTable# ADD tecnici VARCHAR(250) NOT NULL";
/*nuDebug('run2-> '.$sql);*/
nuRunQuery($sql);
/* Work on temp table*/
$sql = "SELECT * FROM #browseTable#";
/*nuDebug('run3-> '.$sql);*/
$rs = nuRunQuery($sql);
/* get technicians related to each appointment*/
while ($row = db_fetch_object($rs)) {
$appID = $row->app_id; /* get appointment ID*/
$tecnici = getTechnician($appID); /* get technician from DB*/
$tecnici = $tecnici[0]; /* get only names*/
/* Update temp table with technician names*/
$sql = "UPDATE #browseTable# SET tecnici = '".$tecnici."' WHERE app_id = '".$appID."'";
/*nuDebug('run4-> '.$sql);*/
nuRunQuery($sql);
}