Skip to content
Snippets Groups Projects
Commit d8ef5191 authored by Patrick Barroca's avatar Patrick Barroca :grin:
Browse files

dev #15795 : id_int_bib used PhasePatrons

parent b524d7b5
Branches
Tags
3 merge requests!2334Master,!2107Dev#15795 1155 importer la bibliotheque de rattachement dans les comptes lecteurs,!2070Dev#15795 1155 importer la bibliotheque de rattachement dans les comptes lecteurs
Pipeline #688 failed with stage
in 19 minutes and 34 seconds
......@@ -137,7 +137,7 @@ class abonne {
$enreg["ID_SITE"] = $enreg['ID_INT_BIB'] = $this->id_int_bib;
$enreg["LOGIN"] = $enreg["IDABON"];
$enreg["ROLE"] = "abonne_sigb";
$enreg["ROLE_LEVEL"] = 2;
$enreg["ROLE_LEVEL"] = ZendAfi_Acl_AdminControllerRoles::ABONNE_SIGB;
$enreg["STATUT"] = 0;
if (isset($enreg["ORDREABON"]) && ((int)$enreg["ORDREABON"] < 1 ))
......
......@@ -73,18 +73,26 @@ class Class_Cosmogramme_Integration_PhasePatrons extends Class_Cosmogramme_Integ
}
/** in case of full import, implements what is needed to be done before importing data */
protected function _clean($integration) {
$this->_markUsersForDeletion($integration);
return $this;
}
protected function _markUsersForDeletion($integration) {
$users = Class_Users::findAllBy(['role_level' => ZendAfi_Acl_AdminControllerRoles::ABONNE_SIGB,
'statut not' => Class_Users::STATUT_TO_BE_DELETED]);
'statut not' => Class_Users::STATUT_TO_BE_DELETED,
'id_int_bib' => $integration->getIdBib()]);
array_map(
function($user) {
Class_Users::getLoader()->save($user->setStatut(1));
Class_Users::getLoader()
->save($user->setStatut(Class_Users::STATUT_TO_BE_DELETED));
},
$users);
}
/** should return true if $line must not be processed */
protected function _shouldIgnoreLine($line, $integration) {
return $line->withDataDo([$this, 'isHeader']);
}
......@@ -100,7 +108,6 @@ class Class_Cosmogramme_Integration_PhasePatrons extends Class_Cosmogramme_Integ
}
/** return true if given profil parameters are correct for this phase */
protected function _validateProfil($profil) {
if (!$profil->isPatrons())
return false;
......@@ -126,10 +133,11 @@ class Class_Cosmogramme_Integration_PhasePatrons extends Class_Cosmogramme_Integ
return empty($errors);
}
/** hooked called after the file has been fully processed */
protected function _afterFileProcessed($integration) {
if (!$count = Class_Users::countBy(['role_level' => ZendAfi_Acl_AdminControllerRoles::ABONNE_SIGB,
'statut' => Class_Users::STATUT_TO_BE_DELETED]))
'statut' => Class_Users::STATUT_TO_BE_DELETED,
'id_int_bib' => $integration->getIdBib()]))
return;
$this->_log->ecrire('<span class="violet">'
......
......@@ -47,26 +47,26 @@ class UsersLoader extends Storm_Model_Loader {
if (!$patron)
return null;
if (! $id_site = $patron->getIdSite())
if (!$id_int_bib = $patron->getIdIntBib())
return null;
if (($ordreabon = $patron->getOrdreabon())
&& ($user = Class_Users::findFirstBy(['login' => $patron->getLogin(),
'ordreabon' => $ordreabon,
'id_site' => $id_site])))
'id_int_bib' => $id_int_bib])))
return $user;
if ($user = Class_Users::findFirstBy(['login' => $patron->getLogin(),
'id_sigb' => $patron->getIdSigb(),
'id_site' => $id_site]))
'id_int_bib' => $id_int_bib]))
return $user;
if ($user = Class_Users::findFirstBy(['login' => $patron->getLogin(),
'id_site' => $id_site]))
'id_int_bib' => $id_int_bib]))
return $user;
if (($id_sigb = $patron->getIdSigb())
&& ($user = Class_Users::findFirstBy(['id_site' => $id_site,
&& ($user = Class_Users::findFirstBy(['id_int_bib' => $id_int_bib,
'id_sigb' => $patron->getIdSigb()])))
return $user;
......
......@@ -32,6 +32,22 @@ abstract class PhasePatronsTestCase extends Class_Cosmogramme_Integration_PhaseT
['id' => 1,
'libelle' => 'Annecy']);
$this->fixture('Class_CodifAnnexe',
['id' => 34,
'id_origine' => 'ANNECY',
'code' => 'ANNECY',
'id_bib' => 1]);
$this->fixture('Class_Bib',
['id' => 2,
'libelle' => 'Seynod']);
$this->fixture('Class_CodifAnnexe',
['id' => 35,
'id_origine' => 'SEYNOD',
'code' => 'SEYNOD',
'id_bib' => 2]);
$this->fixture('Class_IntBib',
['id' => 1,
'sigb' => Class_IntBib::COM_NANOOK,
......@@ -44,7 +60,7 @@ abstract class PhasePatronsTestCase extends Class_Cosmogramme_Integration_PhaseT
'accents' => Class_IntProfilDonnees::ENCODING_UTF8,
'type_fichier' => Class_IntProfilDonnees::FT_PATRONS,
'format' => Class_IntProfilDonnees::FORMAT_PIPED_ASCII,
'attributs' => [1 => ['champs' => 'IDABON;ID_SIGB;ORDREABON;NOM;PRENOM;PASSWORD;MAIL;NAISSANCE ;NULL ; DATE_FIN ']]]);
'attributs' => [1 => ['champs' => 'IDABON;ID_SIGB;ORDREABON;NOM;PRENOM;PASSWORD;MAIL;NAISSANCE ;NULL ; DATE_FIN ;LIBRARY_CODE']]]);
$this->fixture('Class_Cosmogramme_Integration',
['id' => 999,
......@@ -61,6 +77,7 @@ abstract class PhasePatronsTestCase extends Class_Cosmogramme_Integration_PhaseT
'password' => 'force',
'role_level' => ZendAfi_Acl_AdminControllerRoles::ABONNE_SIGB,
'bib' => $bib_annecy,
'id_int_bib' => 1,
'idabon' => '666']);
$this->fixture('Class_Users',
......@@ -69,7 +86,17 @@ abstract class PhasePatronsTestCase extends Class_Cosmogramme_Integration_PhaseT
'password' => '2001',
'role_level' => ZendAfi_Acl_AdminControllerRoles::ABONNE_SIGB,
'bib' => $bib_annecy,
'id_int_bib' => 1,
'idabon' => 'A-000208']);
$this->fixture('Class_Users',
['id' => 3,
'login' => 'D2R2',
'password' => 'bip',
'role_level' => ZendAfi_Acl_AdminControllerRoles::ABONNE_SIGB,
'bib' => $bib_annecy,
'id_int_bib' => 42,
'idabon' => 'D2R2']);
}
......@@ -94,8 +121,8 @@ class PhasePatronsFullImportTest extends PhasePatronsTestCase {
/** @test */
public function numberOfPatronsShouldBeFive() {
$this->assertEquals(5, Class_Users::countBy([]));
public function numberOfPatronsShouldBeSix() {
$this->assertEquals(6, Class_Users::countBy([]));
}
......@@ -201,15 +228,32 @@ class PhasePatronsFullImportTest extends PhasePatronsTestCase {
}
/**
* @depends barryWhiteShouldBeImported
* @test
*/
public function barryLibraryShouldBeAnnecy($barry) {
$this->assertEquals('Annecy', $barry->getBib()->getLibelle());
}
/** @test */
public function thirdAbonneMailShouldBePDotChhieng() {
$chhieng = Class_Users::find(4);
public function chiengPinkMailShouldBePDotChhieng() {
$chhieng = Class_Users::findFirstBy(['login' => 'A-000893']);
$this->assertEquals('p.chhieng@mailoo.com', $chhieng->getMail());
}
/** @test */
public function vadorStatutShouldBeOne() {
public function chiengPinkLibraryShouldBeSeynod() {
$chhieng = Class_Users::findFirstBy(['login' => 'A-000893']);
$this->assertEquals('Seynod', $chhieng->getBib()->getLibelle());
}
/** @test */
public function vadorStatutShouldBeMarkedForDeletion() {
$this->assertEquals(Class_Users::STATUT_TO_BE_DELETED,
Class_Users::find(1)->getStatut());
}
......@@ -217,7 +261,13 @@ class PhasePatronsFullImportTest extends PhasePatronsTestCase {
/** @test */
public function mieszkalskiShouldNotBeMarkedForDeletion() {
$this->assertEquals(0, Class_Users::find(2)->getStatut());
$this->assertEquals(0, Class_Users::findFirstBy(['login' => 'A-000208'])->getStatut());
}
/** @test */
public function moustakiLibraryShouldBeAnnecy() {
$this->assertEquals('Annecy', Class_Users::findFirstBy(['nom' => 'MOUSTAKI'])->getBib()->getLibelle());
}
}
......@@ -245,7 +295,7 @@ class PhasePatronsInvalidProfilTest extends PhasePatronsTestCase {
$this->_phase->run();
$this->assertLogContains('Configuration: colonne ' . $column . ' requise');
$this->assertEquals(2, Class_Users::count());
$this->assertEquals(3, Class_Users::count());
}
}
......@@ -271,8 +321,8 @@ class PhasePatronsPartialImportTest extends PhasePatronsTestCase {
/** @test */
public function numberOfPatronsShouldBeFour() {
$this->assertEquals(4, Class_Users::countBy([]));
public function numberOfPatronsShouldBeFive() {
$this->assertEquals(5, Class_Users::countBy([]));
}
......@@ -317,8 +367,8 @@ class PhasePatronsFullImportXMLTest extends PhasePatronsTestCase {
/** @test */
public function nubmerOfPatronsShouldBeThree() {
$this->assertEquals(3, Class_Users::count());
public function nubmerOfPatronsShouldBeFour() {
$this->assertEquals(4, Class_Users::count());
}
......
BIB_ABON_CARTE|ID_ABON|ORDRE|NOM|PRENOM|MOT_DE_PASSE|E_MAIL|NAISSANCE|TRUC|DATE_FIN
A-000208|54923|2|MIESZKALSKI|brown|2001||2007-07-20|zork|2011-08-28
A-000033|47|1|BARRY|white|1978||1978-05-19||2006-03-23
A-000893|72|1|CHHIENG|pink|1965|p.chhieng@mailoo.com|1964-03-05|bidule|2015-07-04
A-000123|89|1|MOUSTAKI|Georges|1936|papayoyo@dead.fr|1935-02-22| |2016-06-16
BIB_ABON_CARTE|ID_ABON|ORDRE|NOM|PRENOM|MOT_DE_PASSE|E_MAIL|NAISSANCE|TRUC|DATE_FIN|LIBRARY_CODE
A-000208|54923|2|MIESZKALSKI|brown|2001||2007-07-20|zork|2011-08-28|
A-000033|47|1|BARRY|white|1978||1978-05-19||2006-03-23|ANNECY
A-000893|72|1|CHHIENG|pink|1965|p.chhieng@mailoo.com|1964-03-05|bidule|2015-07-04|SEYNOD
A-000123|89|1|MOUSTAKI|Georges|1936|papayoyo@dead.fr|1935-02-22| |2016-06-16|POUET
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment